aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7164
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2010-07-31 15:17:51 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 05:55:12 -0400
commit0b62ceb03545099f0ab43a787cef5307b34b2fe4 (patch)
treeb63d010d27d9bb9506c70a87f32267ec5aaa2d57 /drivers/media/video/saa7164
parent6d152c200e8630dcebcac094d4beff37c1288281 (diff)
[media] saa7164: collect/show the firmware debugging via a thread
Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7164')
-rw-r--r--drivers/media/video/saa7164/saa7164-api.c5
-rw-r--r--drivers/media/video/saa7164/saa7164-core.c88
-rw-r--r--drivers/media/video/saa7164/saa7164.h10
3 files changed, 92 insertions, 11 deletions
diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
index 01cf4ab13b0f..cf8337dd7bdf 100644
--- a/drivers/media/video/saa7164/saa7164-api.c
+++ b/drivers/media/video/saa7164/saa7164-api.c
@@ -24,7 +24,7 @@
24 24
25#include "saa7164.h" 25#include "saa7164.h"
26 26
27int saa7164_api_collect_debug(struct saa7164_dev *dev, struct seq_file *m) 27int saa7164_api_collect_debug(struct saa7164_dev *dev)
28{ 28{
29 tmComResDebugGetData_t d; 29 tmComResDebugGetData_t d;
30 u8 more = 255; 30 u8 more = 255;
@@ -45,8 +45,7 @@ int saa7164_api_collect_debug(struct saa7164_dev *dev, struct seq_file *m)
45 if (d.dwResult != SAA_OK) 45 if (d.dwResult != SAA_OK)
46 break; 46 break;
47 47
48 seq_printf(m, "%s", d.ucDebugData); 48 printk(KERN_INFO "saa7164[%d]-FWMSG: %s", dev->nr, d.ucDebugData);
49
50 } 49 }
51 50
52 return 0; 51 return 0;
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
index 9f97785447f4..db4b39cb72ac 100644
--- a/drivers/media/video/saa7164/saa7164-core.c
+++ b/drivers/media/video/saa7164/saa7164-core.c
@@ -1112,15 +1112,51 @@ static int saa7164_proc_show(struct seq_file *m, void *v)
1112 dev = list_entry(list, struct saa7164_dev, devlist); 1112 dev = list_entry(list, struct saa7164_dev, devlist);
1113 seq_printf(m, "%s = %p\n", dev->name, dev); 1113 seq_printf(m, "%s = %p\n", dev->name, dev);
1114 1114
1115 if (dev->board != SAA7164_BOARD_UNKNOWN) {
1116 seq_printf(m, "Firmware messages ----->\n");
1117 saa7164_api_collect_debug(dev, m);
1118 seq_printf(m, "<---- Firmware messages\n");
1119 }
1120
1121 /* Lock the bus from any other access */ 1115 /* Lock the bus from any other access */
1122 b = &dev->bus; 1116 b = &dev->bus;
1123 mutex_lock(&b->lock); 1117 mutex_lock(&b->lock);
1118
1119 seq_printf(m, " .m_pdwSetWritePos = 0x%x (0x%08x)\n",
1120 b->m_dwSetReadPos, saa7164_readl(b->m_dwSetReadPos));
1121
1122 seq_printf(m, " .m_pdwSetReadPos = 0x%x (0x%08x)\n",
1123 b->m_dwSetWritePos, saa7164_readl(b->m_dwSetWritePos));
1124
1125 seq_printf(m, " .m_pdwGetWritePos = 0x%x (0x%08x)\n",
1126 b->m_dwGetReadPos, saa7164_readl(b->m_dwGetReadPos));
1127
1128 seq_printf(m, " .m_pdwGetReadPos = 0x%x (0x%08x)\n",
1129 b->m_dwGetWritePos, saa7164_readl(b->m_dwGetWritePos));
1130 c = 0;
1131 seq_printf(m, "\n Set Ring:\n");
1132 seq_printf(m, "\n addr 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
1133 for (i = 0; i < b->m_dwSizeSetRing; i++) {
1134 if (c == 0)
1135 seq_printf(m, " %04x:", i);
1136
1137 seq_printf(m, " %02x", *(b->m_pdwSetRing + i));
1138
1139 if (++c == 16) {
1140 seq_printf(m, "\n");
1141 c = 0;
1142 }
1143 }
1144
1145 c = 0;
1146 seq_printf(m, "\n Get Ring:\n");
1147 seq_printf(m, "\n addr 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
1148 for (i = 0; i < b->m_dwSizeGetRing; i++) {
1149 if (c == 0)
1150 seq_printf(m, " %04x:", i);
1151
1152 seq_printf(m, " %02x", *(b->m_pdwGetRing + i));
1153
1154 if (++c == 16) {
1155 seq_printf(m, "\n");
1156 c = 0;
1157 }
1158 }
1159
1124 mutex_unlock(&b->lock); 1160 mutex_unlock(&b->lock);
1125 1161
1126 } 1162 }
@@ -1152,6 +1188,31 @@ static int saa7164_proc_create(void)
1152} 1188}
1153#endif 1189#endif
1154 1190
1191static int saa7164_thread_function(void *data)
1192{
1193 struct saa7164_dev *dev = data;
1194
1195 dprintk(DBGLVL_THR, "thread started\n");
1196
1197 set_freezable();
1198
1199 while (1) {
1200 msleep_interruptible(100);
1201 if (kthread_should_stop())
1202 break;
1203 try_to_freeze();
1204
1205 dprintk(DBGLVL_THR, "thread running\n");
1206
1207 /* Dump the firmware debug message to console */
1208 saa7164_api_collect_debug(dev);
1209
1210 }
1211
1212 dprintk(DBGLVL_THR, "thread exiting\n");
1213 return 0;
1214}
1215
1155static int __devinit saa7164_initdev(struct pci_dev *pci_dev, 1216static int __devinit saa7164_initdev(struct pci_dev *pci_dev,
1156 const struct pci_device_id *pci_id) 1217 const struct pci_device_id *pci_id)
1157{ 1218{
@@ -1313,6 +1374,14 @@ static int __devinit saa7164_initdev(struct pci_dev *pci_dev,
1313 } 1374 }
1314 saa7164_api_set_debug(dev, fw_debug); 1375 saa7164_api_set_debug(dev, fw_debug);
1315 1376
1377 if (fw_debug) {
1378 dev->kthread = kthread_run(saa7164_thread_function, dev,
1379 "saa7164 debug");
1380 if (!dev->kthread)
1381 printk(KERN_ERR "%s() Failed to create "
1382 "debug kernel thread\n", __func__);
1383 }
1384
1316 } /* != BOARD_UNKNOWN */ 1385 } /* != BOARD_UNKNOWN */
1317 else 1386 else
1318 printk(KERN_ERR "%s() Unsupported board detected, " 1387 printk(KERN_ERR "%s() Unsupported board detected, "
@@ -1340,8 +1409,13 @@ static void __devexit saa7164_finidev(struct pci_dev *pci_dev)
1340{ 1409{
1341 struct saa7164_dev *dev = pci_get_drvdata(pci_dev); 1410 struct saa7164_dev *dev = pci_get_drvdata(pci_dev);
1342 1411
1343 if (dev->board != SAA7164_BOARD_UNKNOWN) 1412 if (dev->board != SAA7164_BOARD_UNKNOWN) {
1413 if (fw_debug && dev->kthread) {
1414 kthread_stop(dev->kthread);
1415 dev->kthread = NULL;
1416 }
1344 saa7164_api_set_debug(dev, 0x00); 1417 saa7164_api_set_debug(dev, 0x00);
1418 }
1345 1419
1346 saa7164_histogram_print(&dev->ports[ SAA7164_PORT_ENC1 ], 1420 saa7164_histogram_print(&dev->ports[ SAA7164_PORT_ENC1 ],
1347 &dev->ports[ SAA7164_PORT_ENC1 ].irq_interval); 1421 &dev->ports[ SAA7164_PORT_ENC1 ].irq_interval);
diff --git a/drivers/media/video/saa7164/saa7164.h b/drivers/media/video/saa7164/saa7164.h
index e2de805c30c1..88b9b91bf4f5 100644
--- a/drivers/media/video/saa7164/saa7164.h
+++ b/drivers/media/video/saa7164/saa7164.h
@@ -51,6 +51,8 @@
51#include <linux/version.h> 51#include <linux/version.h>
52#include <linux/mutex.h> 52#include <linux/mutex.h>
53#include <linux/crc32.h> 53#include <linux/crc32.h>
54#include <linux/kthread.h>
55#include <linux/freezer.h>
54 56
55#include <media/tuner.h> 57#include <media/tuner.h>
56#include <media/tveeprom.h> 58#include <media/tveeprom.h>
@@ -109,6 +111,7 @@
109#define DBGLVL_BUF 512 111#define DBGLVL_BUF 512
110#define DBGLVL_ENC 1024 112#define DBGLVL_ENC 1024
111#define DBGLVL_VBI 2048 113#define DBGLVL_VBI 2048
114#define DBGLVL_THR 4096
112 115
113#define SAA7164_NORMS ( V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 ) 116#define SAA7164_NORMS ( V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 )
114 117
@@ -471,6 +474,11 @@ struct saa7164_dev {
471 /* Deferred command/api interrupts handling */ 474 /* Deferred command/api interrupts handling */
472 struct work_struct workcmd; 475 struct work_struct workcmd;
473 476
477 /* A kernel thread to monitor the firmware log, used
478 * only in debug mode.
479 */
480 struct task_struct *kthread;
481
474}; 482};
475 483
476extern struct list_head saa7164_devlist; 484extern struct list_head saa7164_devlist;
@@ -542,7 +550,7 @@ int saa7164_api_set_audio_detection(struct saa7164_port *port, int autodetect);
542int saa7164_api_get_videomux(struct saa7164_port *port); 550int saa7164_api_get_videomux(struct saa7164_port *port);
543int saa7164_api_set_vbi_format(struct saa7164_port *port); 551int saa7164_api_set_vbi_format(struct saa7164_port *port);
544int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level); 552int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level);
545int saa7164_api_collect_debug(struct saa7164_dev *dev, struct seq_file *m); 553int saa7164_api_collect_debug(struct saa7164_dev *dev);
546 554
547/* ----------------------------------------------------------- */ 555/* ----------------------------------------------------------- */
548/* saa7164-cards.c */ 556/* saa7164-cards.c */