aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-debugifc.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-debugifc.c177
1 files changed, 4 insertions, 173 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
index 6f135f4a249..b0687430fdd 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
@@ -31,14 +31,6 @@ struct debugifc_mask_item {
31 unsigned long msk; 31 unsigned long msk;
32}; 32};
33 33
34static struct debugifc_mask_item mask_items[] = {
35 {"ENC_FIRMWARE",(1<<PVR2_SUBSYS_B_ENC_FIRMWARE)},
36 {"ENC_CFG",(1<<PVR2_SUBSYS_B_ENC_CFG)},
37 {"DIG_RUN",(1<<PVR2_SUBSYS_B_DIGITIZER_RUN)},
38 {"USB_RUN",(1<<PVR2_SUBSYS_B_USBSTREAM_RUN)},
39 {"ENC_RUN",(1<<PVR2_SUBSYS_B_ENC_RUN)},
40};
41
42 34
43static unsigned int debugifc_count_whitespace(const char *buf, 35static unsigned int debugifc_count_whitespace(const char *buf,
44 unsigned int count) 36 unsigned int count)
@@ -148,134 +140,14 @@ static int debugifc_match_keyword(const char *buf,unsigned int count,
148} 140}
149 141
150 142
151static unsigned long debugifc_find_mask(const char *buf,unsigned int count)
152{
153 struct debugifc_mask_item *mip;
154 unsigned int idx;
155 for (idx = 0; idx < ARRAY_SIZE(mask_items); idx++) {
156 mip = mask_items + idx;
157 if (debugifc_match_keyword(buf,count,mip->name)) {
158 return mip->msk;
159 }
160 }
161 return 0;
162}
163
164
165static int debugifc_print_mask(char *buf,unsigned int sz,
166 unsigned long msk,unsigned long val)
167{
168 struct debugifc_mask_item *mip;
169 unsigned int idx;
170 int bcnt = 0;
171 int ccnt;
172 for (idx = 0; idx < ARRAY_SIZE(mask_items); idx++) {
173 mip = mask_items + idx;
174 if (!(mip->msk & msk)) continue;
175 ccnt = scnprintf(buf,sz,"%s%c%s",
176 (bcnt ? " " : ""),
177 ((mip->msk & val) ? '+' : '-'),
178 mip->name);
179 sz -= ccnt;
180 buf += ccnt;
181 bcnt += ccnt;
182 }
183 return bcnt;
184}
185
186static unsigned int debugifc_parse_subsys_mask(const char *buf,
187 unsigned int count,
188 unsigned long *mskPtr,
189 unsigned long *valPtr)
190{
191 const char *wptr;
192 unsigned int consume_cnt = 0;
193 unsigned int scnt;
194 unsigned int wlen;
195 int mode;
196 unsigned long m1,msk,val;
197
198 msk = 0;
199 val = 0;
200
201 while (count) {
202 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
203 if (!scnt) break;
204 consume_cnt += scnt; count -= scnt; buf += scnt;
205 if (!wptr) break;
206
207 mode = 0;
208 if (wlen) switch (wptr[0]) {
209 case '+':
210 wptr++;
211 wlen--;
212 break;
213 case '-':
214 mode = 1;
215 wptr++;
216 wlen--;
217 break;
218 }
219 if (!wlen) continue;
220 m1 = debugifc_find_mask(wptr,wlen);
221 if (!m1) break;
222 msk |= m1;
223 if (!mode) val |= m1;
224 }
225 *mskPtr = msk;
226 *valPtr = val;
227 return consume_cnt;
228}
229
230
231int pvr2_debugifc_print_info(struct pvr2_hdw *hdw,char *buf,unsigned int acnt) 143int pvr2_debugifc_print_info(struct pvr2_hdw *hdw,char *buf,unsigned int acnt)
232{ 144{
233 int bcnt = 0; 145 int bcnt = 0;
234 int ccnt; 146 int ccnt;
235 struct pvr2_hdw_debug_info dbg; 147 ccnt = scnprintf(buf,acnt,"Driver state info:\n");
236
237 pvr2_hdw_get_debug_info(hdw,&dbg);
238
239 ccnt = scnprintf(buf,acnt,"big lock %s; ctl lock %s",
240 (dbg.big_lock_held ? "held" : "free"),
241 (dbg.ctl_lock_held ? "held" : "free"));
242 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
243 if (dbg.ctl_lock_held) {
244 ccnt = scnprintf(buf,acnt,"; cmd_state=%d cmd_code=%d"
245 " cmd_wlen=%d cmd_rlen=%d"
246 " wpend=%d rpend=%d tmout=%d rstatus=%d"
247 " wstatus=%d",
248 dbg.cmd_debug_state,dbg.cmd_code,
249 dbg.cmd_debug_write_len,
250 dbg.cmd_debug_read_len,
251 dbg.cmd_debug_write_pend,
252 dbg.cmd_debug_read_pend,
253 dbg.cmd_debug_timeout,
254 dbg.cmd_debug_rstatus,
255 dbg.cmd_debug_wstatus);
256 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
257 }
258 ccnt = scnprintf(buf,acnt,"\n");
259 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
260 ccnt = scnprintf(
261 buf,acnt,"driver flags: %s %s %s\n",
262 (dbg.flag_init_ok ? "initialized" : "uninitialized"),
263 (dbg.flag_ok ? "ok" : "fail"),
264 (dbg.flag_disconnected ? "disconnected" : "connected"));
265 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
266 ccnt = scnprintf(buf,acnt,"Subsystems enabled / configured: ");
267 bcnt += ccnt; acnt -= ccnt; buf += ccnt; 148 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
268 ccnt = debugifc_print_mask(buf,acnt,dbg.subsys_flags,dbg.subsys_flags); 149 ccnt = pvr2_hdw_state_report(hdw,buf,acnt);
269 bcnt += ccnt; acnt -= ccnt; buf += ccnt; 150 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
270 ccnt = scnprintf(buf,acnt,"\n");
271 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
272 ccnt = scnprintf(buf,acnt,"Subsystems disabled / unconfigured: ");
273 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
274 ccnt = debugifc_print_mask(buf,acnt,~dbg.subsys_flags,dbg.subsys_flags);
275 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
276 ccnt = scnprintf(buf,acnt,"\n");
277 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
278
279 ccnt = scnprintf(buf,acnt,"Attached I2C modules:\n"); 151 ccnt = scnprintf(buf,acnt,"Attached I2C modules:\n");
280 bcnt += ccnt; acnt -= ccnt; buf += ccnt; 152 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
281 ccnt = pvr2_i2c_report(hdw,buf,acnt); 153 ccnt = pvr2_i2c_report(hdw,buf,acnt);
@@ -290,7 +162,6 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
290{ 162{
291 int bcnt = 0; 163 int bcnt = 0;
292 int ccnt; 164 int ccnt;
293 unsigned long msk;
294 int ret; 165 int ret;
295 u32 gpio_dir,gpio_in,gpio_out; 166 u32 gpio_dir,gpio_in,gpio_out;
296 167
@@ -311,28 +182,6 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
311 pvr2_hdw_get_streaming(hdw) ? "on" : "off"); 182 pvr2_hdw_get_streaming(hdw) ? "on" : "off");
312 bcnt += ccnt; acnt -= ccnt; buf += ccnt; 183 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
313 184
314 msk = pvr2_hdw_subsys_get(hdw);
315 ccnt = scnprintf(buf,acnt,"Subsystems enabled / configured: ");
316 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
317 ccnt = debugifc_print_mask(buf,acnt,msk,msk);
318 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
319 ccnt = scnprintf(buf,acnt,"\n");
320 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
321 ccnt = scnprintf(buf,acnt,"Subsystems disabled / unconfigured: ");
322 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
323 ccnt = debugifc_print_mask(buf,acnt,~msk,msk);
324 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
325 ccnt = scnprintf(buf,acnt,"\n");
326 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
327
328 msk = pvr2_hdw_subsys_stream_get(hdw);
329 ccnt = scnprintf(buf,acnt,"Subsystems stopped on stream shutdown: ");
330 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
331 ccnt = debugifc_print_mask(buf,acnt,msk,msk);
332 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
333 ccnt = scnprintf(buf,acnt,"\n");
334 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
335
336 return bcnt; 185 return bcnt;
337} 186}
338 187
@@ -369,28 +218,10 @@ static int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
369 return pvr2_upload_firmware2(hdw); 218 return pvr2_upload_firmware2(hdw);
370 } else if (debugifc_match_keyword(wptr,wlen,"decoder")) { 219 } else if (debugifc_match_keyword(wptr,wlen,"decoder")) {
371 return pvr2_hdw_cmd_decoder_reset(hdw); 220 return pvr2_hdw_cmd_decoder_reset(hdw);
221 } else if (debugifc_match_keyword(wptr,wlen,"worker")) {
222 return pvr2_hdw_untrip(hdw);
372 } 223 }
373 return -EINVAL; 224 return -EINVAL;
374 } else if (debugifc_match_keyword(wptr,wlen,"subsys_flags")) {
375 unsigned long msk = 0;
376 unsigned long val = 0;
377 if (debugifc_parse_subsys_mask(buf,count,&msk,&val) != count) {
378 pvr2_trace(PVR2_TRACE_DEBUGIFC,
379 "debugifc parse error on subsys mask");
380 return -EINVAL;
381 }
382 pvr2_hdw_subsys_bit_chg(hdw,msk,val);
383 return 0;
384 } else if (debugifc_match_keyword(wptr,wlen,"stream_flags")) {
385 unsigned long msk = 0;
386 unsigned long val = 0;
387 if (debugifc_parse_subsys_mask(buf,count,&msk,&val) != count) {
388 pvr2_trace(PVR2_TRACE_DEBUGIFC,
389 "debugifc parse error on stream mask");
390 return -EINVAL;
391 }
392 pvr2_hdw_subsys_stream_bit_chg(hdw,msk,val);
393 return 0;
394 } else if (debugifc_match_keyword(wptr,wlen,"cpufw")) { 225 } else if (debugifc_match_keyword(wptr,wlen,"cpufw")) {
395 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen); 226 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
396 if (!scnt) return -EINVAL; 227 if (!scnt) return -EINVAL;