﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	mlocked
9191	Channel switching doesn't work with cx18 driver	Artem Astafyev	danielk	"I can successfully tune any analog channel but when I try to switch to any other channel I get such error:

{{{
2010-11-06 20:51:27.840 TVRec(1): Recorder paused, calling TuningFrequency
2010-11-06 20:51:27.858 Channel(/dev/video0)::SwitchToInput(in 1, '')
2010-11-06 20:51:27.876 Channel(/dev/video0): SetInputAndFormat(1, SECAM-D) (v4l v2)
2010-11-06 20:51:27.885 Channel(/dev/video0) Error: SetInputAndFormat(1, SECAM-D) 
                        while setting format (v4l v2)
                        eno: Device or resource busy (16)
2010-11-06 20:51:27.893 Channel(/dev/video0): SetInputAndFormat() failed
2010-11-06 20:51:27.901 TVRec(1) Error: Failed to set channel to 32. Reverting to kState_None
}}}

I get this error only with cx18 driver. After investigating libmythtv code and cx18 driver I found the cause. Here is cut from cx18 driver's function that is called from S_STD ioctl:

{{{
        if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ||
            atomic_read(&cx->ana_capturing) > 0) {
                /* Switching standard would turn off the radio or mess
                   with already running streams, prevent that by
                   returning EBUSY. */
                return -EBUSY;
        }
}}}

cx->ana_capturing is atomic_t which increased every time V4L2_ENC_CMD_START ioctl is called and decreased on V4L2_ENC_CMD_STOP ioctl. In addition it seems that cx18 driver has no STREAMOFF ioctl so workaround which is used for ConvertX doesn't work: I get EINVAL.
I'm not so familiar with mythtv coding or v4l2 but I feel that fix should be simple.
I can provide any additional info or test fix if you need."	defect	closed	minor	0.25	MythTV - General	0.23.1	medium	fixed	cx18 SetInputAndFormat		0
