This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TVP5146M2: AM5728-evm with TVP5146m2 module, unable to set format error

Part Number: TVP5146M2
Other Parts Discussed in Thread: TVP5146

Hi All

I am trying to capture a movie from TVP5146 analog video decoder from TVP5146 module on AM5728-evm, and I use 'ti-processor-sdk-linux-am57xx-evm-06.03.00.106' SDK. I followed 'AM5728 VIP and V4L2 interface with TVP5146 Analog Video Decoder Problem' thread, and now I can see these messages on 'dmesg' output.

[    3.547762] tvp514x 4-005d: tvp514x 4-005d decoder driver registered !!
...
[   71.493672] vin3a: Port A: Using subdev tvp514x 4-005d for capture
[   71.556900] vin3a: matched fourcc: UYVY: code: 2006 idx: 0
[   71.556908] vin3a: matched fourcc: YUYV: code: 2006 idx: 1
[   71.556915] vin3a: matched fourcc: VYUY: code: 2006 idx: 2
[   71.556922] vin3a: matched fourcc: YVYU: code: 2006 idx: 3
...
[   71.569860] vin3a-0: device registered as video1
[   71.591215] vin3a-0: device registered as video2
[   71.605026] vin3a-0: device registered as video3
[   71.621337] vin3a-0: device registered as video4
...
[   80.214845] vin3a: subdev default mbus_fmt 0000 is not matched.
[   80.267339] vin3a: init_port set_fmt failed in subdev: (-22)
[   80.267346] vin3a: vip_init_port: g_mbus_fmt subdev mbus_code: 2006 fourcc:UYVY size: 0x0
[   80.267396] vin3a: calc_format_size: fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[   80.267404] vin3a-0: init_stream fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[   80.267408] vin3a-0: init_stream vpdma data type: 0x27
[   80.267414] vin3a-0: vip_init_stream: stream instance 0x00000000ec495000
[   80.303069] vin3a: calc_format_size: fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[   80.303078] vin3a-0: init_stream fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[   80.303082] vin3a-0: init_stream vpdma data type: 0x27
[   80.303088] vin3a-0: vip_init_stream: stream instance 0x00000000ec497000
[   80.329235] vin3a-0: init_stream fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[   80.329239] vin3a-0: init_stream vpdma data type: 0x27
[   80.329246] vin3a-0: vip_init_stream: stream instance 0x00000000ec494000
[   80.329314] vin3a: calc_format_size: fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[   80.329323] vin3a-0: init_stream fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[   80.329326] vin3a-0: init_stream vpdma data type: 0x27
[   80.329333] vin3a-0: vip_init_stream: stream instance 0x00000000ec496000
[   80.386710] vin3a-0: vip_release
[   80.411004] vin3a-0: vip_release_stream: stream instance 0x186bfccdec495000
[   80.412996] vin3a-0: vip_release
[   80.413015] vin3a-0: vip_release_stream: stream instance 0x186bfccdec497000
[   80.432817] vin3a-0: vip_release_stream: stream instance 0x186bfccdec496000
[   80.488057] vin3a-0: vip_release
[   80.488079] vin3a-0: vip_release_stream: stream instance 0x186bfccdec494000
[   80.488085] vin3a: vip_release_port: port instance 0x186bfccded781040

When I run a Yavta command 'yavta -c60 -fUYVY -Fvout_720x576_yuyv.yuv -s720x576 /dev/video1', the system fails to set format:

Device /dev/video1 opened.
Device `vip' on `platform:vip2:vin3a:stream0' is a video output (without mplanes) device.
Unable to set format: Invalid argument (22).

The 'dmesg' output after the execution of yavta command is as below:

[ 1460.287542] vin3a-0: vip_open
[ 1460.312409] vin3a: subdev default mbus_fmt 0000 is not matched.
[ 1460.341420] vin3a: init_port set_fmt failed in subdev: (-22)
[ 1460.341425] vin3a: vip_init_port: g_mbus_fmt subdev mbus_code: 2006 fourcc:UYVY size: 0x0
[ 1460.341471] vin3a: calc_format_size: fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[ 1460.341479] vin3a-0: init_stream fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[ 1460.341482] vin3a-0: init_stream vpdma data type: 0x27
[ 1460.341488] vin3a-0: vip_init_stream: stream instance 0x00000000ec494000
[ 1460.424091] vin3a-0: s_fmt input fourcc:UYVY size: 720x576 bpl:0 img_size:0
[ 1460.424099] vin3a-0: try_fmt fourcc:UYVY size: 720x576
[ 1460.424120] vin3a-0: try_fmt best subdev size: 0x0
[ 1460.424138] vin3a: calc_format_size: fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[ 1460.424142] vin3a-0: s_fmt try_fmt fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[ 1460.424168] vin3a-0: s_fmt fourcc:UYVY size: 128x128 bpl:256 img_size:32768
[ 1460.424173] vin3a-0: s_fmt pix_to_mbus mbus_code: 2006 size: 0x0
[ 1460.453179] vin3a-0: set_fmt failed in subdev
[ 1460.453246] vin3a-0: vip_release
[ 1460.453264] vin3a-0: vip_release_stream: stream instance 0x186bfccdec494000
[ 1460.453271] vin3a: vip_release_port: port instance 0x186bfccded781040

I debuged the code, and I found that when the 'tvp514x_get_pad_format' is called, the 'filed', 'code', 'colorspace', 'width', and 'height' of the returned format is zero. Also 'tvp514x_set_pad_format' always returns 'EINVAL'. Can anyone help me to debug these two functions and find out why the system can't set the format?

I added some debug messages in the 'tvp514x_get_pad_format' and 'tvp514x_set_pad_format' of tvp514x.c file as follow:

static int tvp514x_set_pad_format(struct v4l2_subdev *sd,
				  struct v4l2_subdev_pad_config *cfg,
				  struct v4l2_subdev_format *fmt)
{
	struct tvp514x_decoder *decoder = to_decoder(sd);
	v4l2_info(sd, "Ali-Debug start %s !!\n", __func__);
	v4l2_info(sd, "Ali-Debug %d, %d !!\n", fmt->format.field, V4L2_FIELD_INTERLACED);
	v4l2_info(sd, "Ali-Debug %d, %d !!\n", fmt->format.code, MEDIA_BUS_FMT_UYVY8_2X8);
	v4l2_info(sd, "Ali-Debug %d, %d !!\n", fmt->format.colorspace, V4L2_COLORSPACE_SMPTE170M);
	v4l2_info(sd, "Ali-Debug %ld, %ld !!\n", fmt->format.width, tvp514x_std_list[decoder->current_std].width);
	v4l2_info(sd, "Ali-Debug %ld, %ld !!\n", fmt->format.height, tvp514x_std_list[decoder->current_std].height);

	if (fmt->format.field != V4L2_FIELD_INTERLACED ||
	    fmt->format.code != MEDIA_BUS_FMT_UYVY8_2X8 ||
	    fmt->format.colorspace != V4L2_COLORSPACE_SMPTE170M ||
	    fmt->format.width != tvp514x_std_list[decoder->current_std].width ||
	    fmt->format.height != tvp514x_std_list[decoder->current_std].height)
		return -EINVAL;

	v4l2_info(sd, "Ali-Debug end %s !!\n", __func__);
	decoder->format = fmt->format;

	return 0;
}

static int tvp514x_get_pad_format(struct v4l2_subdev *sd,
				  struct v4l2_subdev_pad_config *cfg,
				  struct v4l2_subdev_format *format)
{
	v4l2_info(sd, "Ali-Debug start %s !!\n", __func__);
	struct tvp514x_decoder *decoder = to_decoder(sd);
	__u32 which = format->which;

	if (format->pad)
		return -EINVAL;

	
	v4l2_info(sd, "Ali-Debug %d !!\n", (which == V4L2_SUBDEV_FORMAT_ACTIVE));
	v4l2_info(sd, "Ali-Debug %d, %d !!\n", decoder->format.field, V4L2_FIELD_INTERLACED);
	v4l2_info(sd, "Ali-Debug %d, %d !!\n", decoder->format.code, MEDIA_BUS_FMT_UYVY8_2X8);
	v4l2_info(sd, "Ali-Debug %d, %d !!\n", decoder->format.colorspace, V4L2_COLORSPACE_SMPTE170M);
	v4l2_info(sd, "Ali-Debug %ld, %ld !!\n", decoder->format.width, tvp514x_std_list[decoder->current_std].width);
	v4l2_info(sd, "Ali-Debug %ld, %ld !!\n", decoder->format.height, tvp514x_std_list[decoder->current_std].height);

	if (which == V4L2_SUBDEV_FORMAT_ACTIVE) {
		format->format = decoder->format;
		return 0;
	}

	format->format.code = MEDIA_BUS_FMT_UYVY8_2X8;
	format->format.width = tvp514x_std_list[decoder->current_std].width;
	format->format.height = tvp514x_std_list[decoder->current_std].height;
	format->format.colorspace = V4L2_COLORSPACE_SMPTE170M;
	format->format.field = V4L2_FIELD_INTERLACED; 

	return 0;
}

And here is the output of dmesg

root@am57xx-evm:~# dmesg | grep 'Ali-Debug'
[   80.208283] tvp514x 4-005d: Ali-Debug start tvp514x_get_pad_format !!
[   80.220990] tvp514x 4-005d: Ali-Debug 1 !!
[   80.251948] tvp514x 4-005d: Ali-Debug 0, 4 !!
[   80.264053] tvp514x 4-005d: Ali-Debug 0, 8198 !!
[   80.272094] tvp514x 4-005d: Ali-Debug 0, 1 !!
[   80.300798] tvp514x 4-005d: Ali-Debug 0, 0 !!
[   80.336792] tvp514x 4-005d: Ali-Debug 0, 0 !!
[   80.405515] tvp514x 4-005d: Ali-Debug start tvp514x_set_pad_format !!
[   80.447949] tvp514x 4-005d: Ali-Debug 0, 4 !!
[   80.455601] tvp514x 4-005d: Ali-Debug 8198, 8198 !!
[   80.504178] tvp514x 4-005d: Ali-Debug 0, 1 !!
[   80.520343] tvp514x 4-005d: Ali-Debug 0, 0 !!
[   80.551447] tvp514x 4-005d: Ali-Debug 0, 0 !!
[  129.879144] tvp514x 4-005d: Ali-Debug start tvp514x_get_pad_format !!
[  129.887134] tvp514x 4-005d: Ali-Debug 1 !!
[  129.891249] tvp514x 4-005d: Ali-Debug 0, 4 !!
[  129.896001] tvp514x 4-005d: Ali-Debug 0, 8198 !!
[  129.900639] tvp514x 4-005d: Ali-Debug 0, 1 !!
[  129.905451] tvp514x 4-005d: Ali-Debug 0, 0 !!
[  129.909863] tvp514x 4-005d: Ali-Debug 0, 0 !!
[  129.914737] tvp514x 4-005d: Ali-Debug start tvp514x_set_pad_format !!
[  129.921226] tvp514x 4-005d: Ali-Debug 0, 4 !!
[  129.928232] tvp514x 4-005d: Ali-Debug 8198, 8198 !!
[  129.934122] tvp514x 4-005d: Ali-Debug 0, 1 !!
[  129.938617] tvp514x 4-005d: Ali-Debug 0, 0 !!
[  129.943025] tvp514x 4-005d: Ali-Debug 0, 0 !!
[  130.031589] tvp514x 4-005d: Ali-Debug start tvp514x_set_pad_format !!
[  130.038071] tvp514x 4-005d: Ali-Debug 1, 4 !!
[  130.042474] tvp514x 4-005d: Ali-Debug 8198, 8198 !!
[  130.047369] tvp514x 4-005d: Ali-Debug 1, 1 !!
[  130.051770] tvp514x 4-005d: Ali-Debug 0, 0 !!
[  130.056142] tvp514x 4-005d: Ali-Debug 0, 0 !!

  • Hi,

    Can anyone help me out on how to solve this problem?

    Also, this is the output of the 'i2cdump' command

    root@am57xx-evm:~# i2cdump -f -y 4 0x5d
    No size specified (using byte-data access)
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    00: 00 0f 00 00 23 10 00 00 02 80 80 80 00 00 0e 00    .?..#?..????..?.
    10: 80 80 80 80 80 80 55 00 25 03 00 00 40 00 04 00    ??????U.%?..@.?.
    20: 07 00 01 00 15 00 00 00 cc 00 00 00 00 00 00 00    ?.?.?...?.......
    30: 00 05 00 40 00 ff ff ff ff 00 11 38 00 00 6a 81    .?.@......?8..j?
    40: 00 20 0d 02 80 04 20 20 20 20 00 09 00 09 00 09    . ????    .?.?.?
    50: 00 09 00 00 1f 1f 64 00 00 00 00 00 00 00 00 00    .?..??d.........
    60: 00 00 00 00 00 00 00 00 00 00 0a 45 08 ff ff 04    ..........?E?..?
    70: 08 00 00 19 00 16 8a 64 06 1e 40 00 00 00 03 00    ?..?.??d??@...?.
    80: 51 46 00 09 00 00 00 00 00 00 00 00 7d 00 00 00    QF.?........}...
    90: 00 20 1d 64 03 00 00 00 00 00 00 00 00 24 00 06    . ?d?........$.?
    a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00    .............?..
    c0: 00 00 1e 00 22 00 50 00 00 00 00 00 00 00 00 00    ..?.".P.........
    d0: 00 00 00 00 00 00 06 1b ff 00 ff 00 00 00 00 00    ......??........
    e0: fb fb 7f 00 fb fb fb fb 01 00 00 00 00 00 00 fb    ???.?????......?
    f0: 00 00 00 00 00 00 00 00 00 fb fb fb fb fb fb fb    .........???????

    Best Regards,
    Ali