cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ram
Observer
Observer
967 Views
Registered: ‎10-09-2018

Custom v4l2 driver to link VPSS input port

Jump to solution

Hi,

 

We have a costom IP(video receiver) which is connected to VPSS. and the VPSS is connected to framebuffer write.

Here I need to create v4l2 sourcepad for our custom IP in order to link vpss sync pad. i am facing little difficulty to configuring Video_ops and pad_ops.

Is there any sollution for this.

 

Thanks and Regards,

Ramaradhya N

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
hokim
Scholar
Scholar
500 Views
Registered: ‎10-21-2015

Hi 

I already give you the answer 

Change tvalid/tready handshake of  your hw design like this

valid_before_ready.png

 

 

 

according to xilinx video IP, data will move from master to slave IP when the tready received from the slave IP

 

 

The above doesn't mean your custom ip should wait for the tready from the slave. It just say that when tready and tvalid are valid, data  transfers

In your case, the slave sends tready signal responding to tvalid of your custom ip 

It is similar to fifo read by slave: the slave send rd_en signal after confirming fifo is not empty 

It is the reason I recommend you to use  Video In to AXI4-Stream IP

View solution in original post

0 Kudos
13 Replies
ram
Observer
Observer
900 Views
Registered: ‎10-09-2018

Adding few more pointes on this.

is it necessory to add s_stream in video_ops. as there is no software register to configure custon IP for stream the video.

As per my knowledge s_stream is used to start/stop the video stream.

so how to configure s_stream of video_ops of v4l2 drivers.

 

Thanks and Regards,

Ramaradhya

0 Kudos
ram
Observer
Observer
855 Views
Registered: ‎10-09-2018

Videolocked is a boolean used to start and stop the video in v4l2 framework.

Need to understand at what condition we need to make videolocked=true and videolocked-false. and where to configure this videolocked boolean,

anny suggestions for the same.

 

thanks and regards,

Ramaradhya N

0 Kudos
hokim
Scholar
Scholar
829 Views
Registered: ‎10-21-2015

Hi

I think you have the answer

Video should start and stop  in  s_stream function

For writing v4l2 sub-device driver, refer to  https://github.com/Xilinx/linux-xlnx/blob/master/drivers/media/platform/xilinx/xilinx-tpg.c

http://kylexu.net/wp-content/uploads/2016/09/Camera-Driver-Development.pdf

0 Kudos
ram
Observer
Observer
762 Views
Registered: ‎10-09-2018

Dear Hokim,

Thanks for the suggesion. i need to understand about ctrl_ops and control handlers.

As my custom IP does not required any software register read write other than enabling and dissabling.

is it mandatary to configure ctrl_ops and control handlers for the v4l2 subdevice driver.

could you please help me to configure ctrl_ops and control handlers for our v4l2 subdevice driver.

 

Thanks and Regards,

Ram

0 Kudos
hokim
Scholar
Scholar
740 Views
Registered: ‎10-21-2015

Hi

You don't need to implement ctrl_ops

I think you need to implement the following at least

static const struct v4l2_subdev_video_ops custom_video_ops = {
	.s_stream = custom_s_stream,
};

static const struct v4l2_subdev_pad_ops custom_pad_ops = {
	.get_fmt		= custom_get_format,
	.set_fmt		= custom_set_format,
};

static const struct v4l2_subdev_ops custom_ops = {
	.video  = &custom_video_ops,
	.pad    = &custom_pad_ops,
};
0 Kudos
ram
Observer
Observer
711 Views
Registered: ‎10-09-2018

Hello Hokin,

Thanks for the quick replay. i refered xilinx-tpg.c test pattern generator driver and configured my driver as shown below

static const struct media_entity_operations custom_media_ops = {
.link_validate = v4l2_subdev_link_validate
};


static const struct v4l2_subdev_core_ops custom_core_ops = {
};


static const struct v4l2_subdev_video_ops custom_video_ops = {
.g_frame_interval = custom_g_frame_interval,
.s_frame_interval = custom_s_frame_interval,
.s_stream = custom_s_stream,
};

static const struct v4l2_subdev_pad_ops custom_pad_ops = {
.get_fmt = custom_get_format,
.set_fmt = custom_set_format,
.enum_mbus_code = xvip_enum_mbus_code,
.enum_frame_size = xvip_enum_frame_size,
};

static const struct v4l2_subdev_ops custom_ops = {
.video = &custom_video_ops,
.pad = &custom_pad_ops,
.pad = &custom_pad_ops,

};

static const struct v4l2_subdev_internal_ops custom_internal_ops = {
.open = custom_open,
.close = custom_close
};

0 Kudos
ram
Observer
Observer
709 Views
Registered: ‎10-09-2018

Hi Hookin,

As i shared video_ops, pad_ops, v4l2_subdev_internal_ops and custom_media_ops, 

Under pad_ops enum_mbus_code, enum_frame_size, .enum_frame_size and enum_dv_timings are not required?

Under video_ops s_frame_interval, g_frame_interval and query_dv_timings are not required?

 

Could you please give your valuable comments.

 

Thanks and Regards,

Ram

0 Kudos
hokim
Scholar
Scholar
672 Views
Registered: ‎10-21-2015

Hi

 

 

static const struct media_entity_operations custom_media_ops = {
.link_validate = v4l2_subdev_link_validate
};

static const struct v4l2_subdev_video_ops custom_video_ops = {
.s_stream = custom_s_stream,
};

static const struct v4l2_subdev_pad_ops custom_pad_ops = {
.get_fmt = custom_get_format,
.set_fmt = custom_set_format,
};

static const struct v4l2_subdev_ops custom_ops = {
.video = &custom_video_ops,
.pad = &custom_pad_ops,

};

 

 

If your hardware supports frame rate control, add .g_frame_interval = custom_g_frame_interval and .s_frame_interval = custom_s_frame_interval

0 Kudos
ram
Observer
Observer
641 Views
Registered: ‎10-09-2018

Hi Hokim,

Thanks for the replay.

Our project path is as shown below

Custom IP -> AXI sub converter->VPSS CSC->Frame buffer write -> DDR

 

I am able to set the media graph as shown below

Media device information
------------------------
driver xilinx-video
model Xilinx Video Composite Device
serial
bus info
hw revision 0x0
driver version 4.19.0

Device topology
- entity 1: vcap_sdirx output 0 (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "80040000.v_proc_ss":1 [ENABLED]

- entity 5: 80040000.v_proc_ss (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev0
pad0: Sink
[fmt:RBG888_1X24/1920x1080 field:none colorspace:srgb]
<- "80020000.M03_AXI_0":0 [ENABLED]
pad1: Source
[fmt:UYVY8_1X16/1920x1080 field:none colorspace:srgb]
-> "vcap_sdirx output 0":0 [ENABLED]

- entity 8: 80020000.M03_AXI_0 (1 pad, 1 link)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Source
[fmt:RBG888_1X24/1920x1080@1/60 field:none colorspace:srgb]
-> "80040000.v_proc_ss":0 [ENABLED]

 

I am trying to stream the video using gstreamer command. but i am unable to get TREADY from Frame buffer write to VPSS CSC and hence VPSS is not giving TREADY to our custom IP. because of this reason i am unable to stream the video.

 

Could you please tel me why frame buffer write is not giving TREADY, is there any dependancy from our custom V4L2 driver for our custom IP.

and we have verified the design by connnecting TPG instead of our custom IP.

TREADY is the problem for us.  Please give your valuable comments.

 

Thanks and Regards,

Ram

 

0 Kudos
hokim
Scholar
Scholar
621 Views
Registered: ‎10-21-2015

Hi

Your custom ip should start/stop its data streaming by enable parameter in custom_s_stream

This is an example

https://github.com/Xilinx/linux-xlnx/blob/master/drivers/media/platform/xilinx/xilinx-hls.c#L178-L195

Your custom ip should not wait for tready and should initiate transaction with tvalid  when there are data to send

To avoid the difficulty of AXI4 Stream generation, I recommend you design your custom ip to generate video signal and  use  Xilinx  Video In to AXI4-Stream IP for AXI4 Stream generation

https://www.xilinx.com/support/documentation/ip_documentation/v_vid_in_axi4s/v4_0/pg043_v_vid_in_axi4s.pdf

https://forums.xilinx.com/t5/Video-and-Audio/Video-Beginner-Series-2-From-Native-video-to-AXI4-Stream/td-p/851073

The following figure shows us how to design video capture ip with AXI4-Stream Master

tready and tvalid are connected to rd_en and ~empty respectively 

tuser and tlast are sof and eol in fifo data respectively

https://www.xilinx.com/support/documentation/ip_documentation/v_vid_in_axi4s/v4_0/pg043_v_vid_in_axi4s.pdf#page=6

 

0 Kudos
ram
Observer
Observer
510 Views
Registered: ‎10-09-2018

Hi Hokim,

Thanks for the quick replay.

As per your suggestion we aplanned to control our custom ip start/stop of data streaming  in custom_s_stream using one register.

but according to xilinx video IP, data will move from master to slave IP when the tready received from the slave IP. here your suggesting us to start sending the data when we configure the reguster in s_stream.

 

could you please give us idea how the ready and s_stream is related.

 

Thanks and Regards,

Ram

 

0 Kudos
hokim
Scholar
Scholar
501 Views
Registered: ‎10-21-2015

Hi 

I already give you the answer 

Change tvalid/tready handshake of  your hw design like this

valid_before_ready.png

 

 

 

according to xilinx video IP, data will move from master to slave IP when the tready received from the slave IP

 

 

The above doesn't mean your custom ip should wait for the tready from the slave. It just say that when tready and tvalid are valid, data  transfers

In your case, the slave sends tready signal responding to tvalid of your custom ip 

It is similar to fifo read by slave: the slave send rd_en signal after confirming fifo is not empty 

It is the reason I recommend you to use  Video In to AXI4-Stream IP

View solution in original post

0 Kudos
ram
Observer
Observer
394 Views
Registered: ‎10-09-2018

Hi Hokim,

Thank you so much for your comments. based on your comments we have modified our custom IP and we are able to stream the Video with UYVY color formate.

and we are using the command as shwon below to set resolution and color space

media-ctl -v -V '"80020000.M03_AXI_0":0 [fmt:RBG888_1X24/1920x1080 field:none]'

media-ctl -v -V '"80040000.v_proc_ss":1 [fmt:UYVY8_1X16/1920x1080 field:none]'

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='UYVY'

and we are streaming the video using below command

gst-launch-1.0 v4l2src num-buffers=500 device=/dev/video0 ! "video/x-raw, width=1920, height=1080,interlace-mode=(string)progressive, format=UYVY, framerate=60/1" ! queue ! fpsdisplaysink name=fpssink text-overlay=false video-sink="kmssink bus-id=fd4a0000.zynqmp-display fullscreen-overlay=1" sync=true -v

but we want to compress the video using xilinx VCU. and VCU accepts only semi-planar  color formats. UYVY is a packed YUV 4:2:2 format. so we tried to modify the command as shown below to capture the video in NV16 format.

v4l2-ctl -d /dev/video0 --set-fmt-video width=1920,height=1080,pixelformat='NV16'

gst-launch-1.0 v4l2src num-buffers=500 device=/dev/video0 ! "video/x-raw, width=1920, height=1080,interlace-mode=(string)progressive, format=NV16, framerate=60/1" ! queue ! fpsdisplaysink name=fpssink text-overlay=false video-sink="kmssink bus-id=fd4a0000.zynqmp-display fullscreen-overlay=1" sync=true -v 

but we are not able to capture the video in NV16 format. and we tried by keeping only NV16 color format for framebuffer to stream video in NV16 format, we are not able to stream the video with NV16.

is this issue is related to our costom driver for our costom IP.

could you please provide your valuable comments.

 

Thanks and Regards,

Ram

0 Kudos