diff options
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-firmware.c')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-firmware.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/media/video/ivtv/ivtv-firmware.c b/drivers/media/video/ivtv/ivtv-firmware.c index a71e8ba306b0..efb288d34ca3 100644 --- a/drivers/media/video/ivtv/ivtv-firmware.c +++ b/drivers/media/video/ivtv/ivtv-firmware.c | |||
@@ -271,3 +271,49 @@ void ivtv_init_mpeg_decoder(struct ivtv *itv) | |||
271 | } | 271 | } |
272 | ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 4, 0, 0, 0, 1); | 272 | ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 4, 0, 0, 0, 1); |
273 | } | 273 | } |
274 | |||
275 | /* Check firmware running state. The checks fall through | ||
276 | allowing multiple failures to be logged. */ | ||
277 | int ivtv_firmware_check(struct ivtv *itv, char *where) | ||
278 | { | ||
279 | int res = 0; | ||
280 | |||
281 | /* Check encoder is still running */ | ||
282 | if (ivtv_vapi(itv, CX2341X_ENC_PING_FW, 0) < 0) { | ||
283 | IVTV_WARN("Encoder has died : %s\n", where); | ||
284 | res = -1; | ||
285 | } | ||
286 | |||
287 | /* Also check audio. Only check if not in use & encoder is okay */ | ||
288 | if (!res && !atomic_read(&itv->capturing) && | ||
289 | (!atomic_read(&itv->decoding) || | ||
290 | (atomic_read(&itv->decoding) < 2 && test_bit(IVTV_F_I_DEC_YUV, | ||
291 | &itv->i_flags)))) { | ||
292 | |||
293 | if (ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12) < 0) { | ||
294 | IVTV_WARN("Audio has died (Encoder OK) : %s\n", where); | ||
295 | res = -2; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { | ||
300 | /* Second audio check. Skip if audio already failed */ | ||
301 | if (res != -2 && read_dec(0x100) != read_dec(0x104)) { | ||
302 | /* Wait & try again to be certain. */ | ||
303 | ivtv_msleep_timeout(14, 0); | ||
304 | if (read_dec(0x100) != read_dec(0x104)) { | ||
305 | IVTV_WARN("Audio has died (Decoder) : %s\n", | ||
306 | where); | ||
307 | res = -1; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | /* Check decoder is still running */ | ||
312 | if (ivtv_vapi(itv, CX2341X_DEC_PING_FW, 0) < 0) { | ||
313 | IVTV_WARN("Decoder has died : %s\n", where); | ||
314 | res = -1; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | return res; | ||
319 | } | ||