18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/************************************************************************ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci AudioScience HPI driver 58c2ecf20Sopenharmony_ci Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciDebug macro translation. 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci************************************************************************/ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include "hpi_internal.h" 138c2ecf20Sopenharmony_ci#include "hpidebug.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* Debug level; 0 quiet; 1 informative, 2 debug, 3 verbose debug. */ 168c2ecf20Sopenharmony_ciint hpi_debug_level = HPI_DEBUG_LEVEL_DEFAULT; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_civoid hpi_debug_init(void) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci printk(KERN_INFO "debug start\n"); 218c2ecf20Sopenharmony_ci} 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciint hpi_debug_level_set(int level) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci int old_level; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci old_level = hpi_debug_level; 288c2ecf20Sopenharmony_ci hpi_debug_level = level; 298c2ecf20Sopenharmony_ci return old_level; 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciint hpi_debug_level_get(void) 338c2ecf20Sopenharmony_ci{ 348c2ecf20Sopenharmony_ci return hpi_debug_level; 358c2ecf20Sopenharmony_ci} 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_civoid hpi_debug_message(struct hpi_message *phm, char *sz_fileline) 388c2ecf20Sopenharmony_ci{ 398c2ecf20Sopenharmony_ci if (phm) { 408c2ecf20Sopenharmony_ci printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version, 418c2ecf20Sopenharmony_ci phm->adapter_index, phm->obj_index, phm->function, 428c2ecf20Sopenharmony_ci phm->u.c.attribute); 438c2ecf20Sopenharmony_ci } 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci} 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_civoid hpi_debug_data(u16 *pdata, u32 len) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci u32 i; 508c2ecf20Sopenharmony_ci int j; 518c2ecf20Sopenharmony_ci int k; 528c2ecf20Sopenharmony_ci int lines; 538c2ecf20Sopenharmony_ci int cols = 8; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci lines = (len + cols - 1) / cols; 568c2ecf20Sopenharmony_ci if (lines > 8) 578c2ecf20Sopenharmony_ci lines = 8; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci for (i = 0, j = 0; j < lines; j++) { 608c2ecf20Sopenharmony_ci printk(KERN_DEBUG "%p:", (pdata + i)); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci for (k = 0; k < cols && i < len; i++, k++) 638c2ecf20Sopenharmony_ci printk(KERN_CONT "%s%04x", k == 0 ? "" : " ", pdata[i]); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci printk(KERN_CONT "\n"); 668c2ecf20Sopenharmony_ci } 678c2ecf20Sopenharmony_ci} 68