[TX2 L4T28.1] How to get embedded data?

Hi,

In TX1, I could get embedded data along with pixel data by setting b[21:20] of CSI_PIXEL_STREAM_A_CONTROL0_0 to 1.

However, I could not find a similar register setting in TX2 TRM.

Could you let me know the register in TX2 to configure to get embedded data (or can it be configured via dtb) ?

Regards,
Rejeesh

@Rejeesh
Please check the …/kernel/kernel-4.4/drivers/media/platform/camera/vi/vi4_fops.c
You should get the information to search the EMB, EMBED_X

@ShaneCCC,

I checked the source code and confirmed that piece of code enabling embedded data is executed.i.e., below piece of code is executed:

if (chan->embedded_data_height > 0) {
		vi4_channel_write(chan, vnc_id, EMBED_X,chan->embedded_data_width * BPP_MEM);
		vi4_channel_write(chan, vnc_id, EMBED_Y,chan->embedded_data_height | EXPECT);
}

EMBED_Y register is rightly set as 0x0100_0001, but not sure about EMBED_X. Its value is 0x1E40.

However, I get timeout error if I configure frame height as actual height + 1 (embedded data height is 1)

tegra-vi4 15700000.vi: Status: 7 channel:00 frame:0007
tegra-vi4 15700000.vi:			timestamp sof xyz eof xyz datat 0x00000001
tegra-vi4 15700000.vi:			capture_id 24047 stream 4 vchan 0
tegra-vi4 15700000.vi: PXL_SOF syncpt timeour! error=-11

And there is no timeout error if I confgure my height as actual height only, which clearly suggest that embedded data is stil discarded by VI module.

Should I configure any other register as well to get embedded data?

Regards,
Rejeesh

@Rejeesh
The frame height should not include the embedded data line.
Try find the embedded data from the emb_buf.

@ShaneCCC,
[i]

The frame height should not include the embedded data line.[/i]
But this is how I was getting embedded data in TX1 (L4T 28.1). So the method has changed in TX2?

>>Try find the embedded data from the emb_buf.
I did not get this point. I saw few buffers like chan->vi->emb_buf_addr in vi4.c, but how do I access these from application.

So, is it not possible to get embedded data along with pixel data in V4L2 buffers? Else how do we sync embedded data for each frame (even if we manage to get embedded data some other way) ?

Regards,
Rejeesh

@Rejeesh
TX1 and TX2 is different VI HW.
I suggestion try to copy the emb_buf to the frame buffer to pass to user space. Maybe you can override the first line and user user space crop it not to use.

@Shane,

I am back to this activity. I tried modifying vi4_fops.c to copy embedded data, but could not exactly figure out where to do it. Could you help me with below queries?

  1. I did a quick walk through and felt that embedded data should be copied inside “tegra_channel_capture_frame” function. Am I right?

  2. I understand that embedded data is stored in “chan->vi->emb_buf_addr”, but could not locate frame buffer? I saw “vb2_v4l2_buffer->vb2_buf”, but its another struct. Could you point to the exact buffer?

Regards,
Rejeesh

@Rejeesh
Yes, the tegra_channel_capture_frame is the correction function to capture a frame from sensor.
Try to dump the data after the vi_notify_wait()

@Shane,

Thank You for the confirmation.

But could you check the 2nd question as well? i.e., what is the name of the frame buffer variable?

Regards,
Rejeesh

@Rejeesh
I am kind of don’t understand your second question.

Embedded data buffer address --> chan->vi->emb_buf_addr
Frame buffer address --> ??

@Rejeesh
It’s the strut of channel_buffer_buffer like buf->addr in the tegra_channel_capture_frame(chan, buf, i);

Not sure I understood it completely.
Are you referring to tegra_channel_buffer->addr? If so, it is dma_addr_t type. How do I get the virtual address from it?
It would be really great if you could provide a patch to capture embedded data.

@Rejeesh
Sorry, I don’t have patch for this. All of the source was public you have to figure it out by yourself.

Hi Shane,

Thank you for your support. I could successfully get embedded data.

Your suggestion worked out - copy embedded buffer to 1st line of frame buffer.

Consolidating modifications here, just in case anyone needs it in future.

Added below piece of code in tegra_channel_capture_frame() in vi4_fops.c

void* frm_buffer = vb2_plane_vaddr(&(vb->vb2_buf), 0);
	if(frm_buffer != NULL) {
		memcpy(frm_buffer,chan->vi->emb_buf_addr,chan->vi->emb_buf_size);
	}

Regards,
Rejeesh