Supporting two video modes

@JerryChang, hi,

I have modified the driver to include some enumeration funtion and now I have the standards depicted in the formats (though one of the formats is duplicated UYVY). How to solve it?

v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
** Type : Video Capture**
** Pixel Format: ‘UYVY’**
** Name : UYVY 4:2:2**
** Size: Discrete 720x576**
** Interval: Discrete 0.040s (25.000 fps)**
** Size: Discrete 720x480**
** Interval: Discrete 0.033s (30.000 fps)**

Index : 1
Type : Video Capture
Pixel Format: ‘NV16’
Name : Y/CbCr 4:2:2
Size: Discrete 720x576
Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 720x480
Interval: Discrete 0.033s (30.000 fps)

Index : 2
** Type : Video Capture**
** Pixel Format: ‘UYVY’**
** Name : UYVY 4:2:2**
** Size: Discrete 720x576**
** Interval: Discrete 0.040s (25.000 fps)**
** Size: Discrete 720x480**
** Interval: Discrete 0.033s (30.000 fps)**

Index : 3
Type : Video Capture
Pixel Format: ‘RGB3’ (emulated)
Name : RGB3
Size: Discrete 720x576
Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 720x480
Interval: Discrete 0.033s (30.000 fps)

Index : 4
Type : Video Capture
Pixel Format: ‘BGR3’ (emulated)
Name : BGR3
Size: Discrete 720x576
Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 720x480
Interval: Discrete 0.033s (30.000 fps)

Index : 5
Type : Video Capture
Pixel Format: ‘YU12’ (emulated)
Name : YU12
Size: Discrete 720x576
Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 720x480
Interval: Discrete 0.033s (30.000 fps)

Index : 6
Type : Video Capture
Pixel Format: ‘YV12’ (emulated)
Name : YV12
Size: Discrete 720x576
Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 720x480
Interval: Discrete 0.033s (30.000 fps)

Moreover I have noticed that when I provide the corret frame rate of NTSC which is 30000/1001 (29.97) there is a failure during encoding:

gst-launch-1.0 v4l2src device=/dev/video0 ! ‘video/x-raw, format=(string)UYVY,width=720,height=480,framerate=(fraction)30000/1001’ ! xvimagesink
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason not-negotiated (-4)
Execution ended after 0:00:01.381554880
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

while when I set the frame of 30 I get the following error:

gst-launch-1.0 v4l2src device=/dev/video0 ! ‘video/x-raw, format=(string)UYVY,width=720,height=480,framerate=(fraction)30’ ! xvimagesink
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
libv4l2: error turning on stream: Connection timed out
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not read from resource.
Additional debug info:
gstv4l2bufferpool.c(1054): gst_v4l2_buffer_pool_poll (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
poll error 1: Connection timed out (110)
Execution ended after 0:00:01.102283008
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

another thing that I have noticed is that when I try to change the mode (from user space) with the following snippet:

struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl;

memset(&ctrls, 0, sizeof(ctrls));
memset(&ctrl, 0, sizeof(ctrl));

ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(TEGRA_CAMERA_CID_SENSOR_MODE_ID);
ctrls.count = 1;
ctrls.controls = &ctrl;

ctrl.id = TEGRA_CAMERA_CID_SENSOR_MODE_ID;
ctrl.value = mode;

ret = ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);

The value that the driver gets does not change, so I am not sure if the mode is changing, though the adv7180_s_ctr function is invoked only if the value of mode in user space changes (0 to 1 or 1 to 0):

[ 45.691993] *********************adv7180_s_power 1
[ 45.697808] *********************adv7180_set_power 1
[ 45.708273] *********************adv7180_s_ctrl is_new 1
[ 45.713734] *********************adv7180_s_ctrl has_changed 1
[ 45.719579] *********************adv7180_s_ctrl is_private 0
[ 45.725354] *********************adv7180_s_ctrl is_string 0
[ 45.731041] *********************adv7180_s_ctrl is_ptr 0
[ 45.736566] *********************adv7180_s_ctrl is_array 0
[ 45.742178] *********************adv7180_s_ctrl has_volatiles 0
[ 45.748317] *********************adv7180_s_ctrl call_notify 0
[ 45.754101] *********************adv7180_s_ctrl manual_mode_value 0
[ 45.760387] *********************adv7180_s_ctrl name Sensor Mode
[ 45.766434] *********************adv7180_s_ctrl flags 0x20
[ 45.771946] *********************adv7180_s_ctrl val 0
[ 45.777006] *********************adv7180_s_ctrl cur.val 0
[ 45.782429] *********************adv7180_s_ctrl 10100744
[ 45.787765] *********************TEGRA_CAMERA_CID_SENSOR_MODE_ID 0

Moreover I do not see that the dv_timing is changin, I am not sure if this is important, as the chip itself is not using it.

bottom line at the moment, PAL works, NTSC does not work.

any suggestions?