On Sun, 2010-11-14 at 20:08 +0200, Artem Astafyev wrote:
> Andy,
>
> You are right. I've checked 0.23.1 tree and it has the same code in
> lib/libmythtv/mpegrecorder.cpp.
> It seems that we have driver name 'cx18' for cx18-based cards and we
> need special case for (driver == "cx18").
> I changed
> has_buggy_vbi = requires_special_pause = false;
> to
> has_buggy_vbi = requires_special_pause = true;
> and now channel switching works fine.
> But now I have another problem :) After switching channel I have
> distorted picture. It looks like b/w picture with vertical RGB lines.
> Also there is no sound, only noise. As tuning was fine this channel
> become default. If I restart LiveTV it looks fine. Below is usecase:
> 1. Default channel 1.
> 2. Start LiveTV. Tuning to default channel 1. Picture and sound fine.
> 3. Switch to channel 2. Tuning fine, but picture distorted, noise.
> 4. Channel 2 become default.
> 5. Stop LiveTV. Start LiveTV. Tuning to default channel 2. Picture and
> sound fine.
> 6. Switch to channel 1. Tuning fine, but picture distorted, noise.
> 7. Swicth any channel. Tuning fine, but picture distorted, noise.
> So I can get normal picture and sound only after LiveTV restart.
> It looks like there is some issue with mpeg encoder restart.
Hmmm....
cx18_v4l2_ioctl()
mutex_lock(&cx->serialize_lock)
video_ioctl2()
cx18_encoder_cmd(..., .. V4L2_ENC_CMD_STOP)
cx18_stop_capture()
cx18_stop_v4l2_encode_stream()
cx18_vapi(..., CX18_CPU_CAPTURE_STOP,
...)
cx18_vapi(..., CX18_CPU_DE_RELEASE_MDL,
...)
^^^ tell firmware to
give back all buffers
cx18_vapi(..., CX18_DESTROY_TASK, ...)
cx18_release_stream()
cx18_flush_queues()
cx18_queue_flush(...,
&s->q_busy, &s->q_free)
cx18_queue_flush(...,
&s->q_full, &s->q_free)
^^^
move the MDLs to q_free
^^^ The above steps are also done for the IDX
and/or VBI streams if needed
mutex_unlock(&cx->serialize_lock)
cx18_v4l2_ioctl()
mutex_lock(&cx->serialize_lock)
video_ioctl2()
cx18_encoder_cmd(..., .. V4L2_ENC_CMD_START)
cx18_start_capture()
cx18_start_v4l2_encode_stream()
cx18_vapi(..., CX18_CREATE_TASK, ...)
cx18_vapi(...,
CX18_CPU_SET_CHANNEL_TYPE, ...)
cx18_vapi() ... more calls to set up
the encoder
cx18_vbi_setup()
(set up A/V decoder and make a
cx18_vapi() call)
cx18_vapi_result(...,
CX18_CPU_SET_INDEXTABLE, ...)
cx2341x_update()
(even more cx18_vapi() calls to
set up encoder)
cx18_api(..., CX18_CPU_DE_SET_MDL_ACK,
...)
cx18_stream_configure_mdls()
cx18_unload_queues()
cx18_queue_flush(...,
&s->q_busy, q_idle)
cx18_queue_flush(...,
&s->q_full, q_idle)
cx18_queue_flush(...,
&s->q_free, q_idle)
move all buffers back
to the buffer pool
cx18_load_queues()
reload usable
MDLs/buffers back to q_free
_cx18_stream_load_fw_queue()
iteratively pop an MDL off of
q_free
_cx18_stream_put_mdl_fw()
put the MDL on q_busy
sync the memory for
device DMA
cx18_vapi(...,
CX18_CPU_DE_SET_MDL, ...)
cx18_vapi(..., CX18_CPU_CAPTURE_START,
...)
^^^ Repeat the above steps for the IDX or VBI
stream, if needed
mutex_unlock(&cx->serialize_lock)
I was going to guess it is a race or a bug involving
cx18_unload_queues(). But now I'm not so sure, since the
&cx->serialize_lock is held.
You probably should set the "debug=" module parameter to the cx18 and
see if you see any races in the log. You'll want to turn on the high
volume, mailbox, dma, ioctl, warn, and info debug flags.
See /sbin/modinfo cx18 .
Or you might just want to add a 3 second delay before libmythtv calls
VIDIOC_ENC_CMD, V4L2_ENC_CMD_START and see if that makes the problem go
away. That would indicate a race in the cx18 driver or firmware if the
problem does go away.
Regards,
Andy
> Thanks,
> Artem Astafyev
_______________________________________________
ivtv-devel mailing list
[email protected]
http://ivtvdriver.org/mailman/listinfo/ivtv-devel