Add support to ITU-R BT.656 video data format
cover Add support to ITU-R BT.656 video data format
This patch-set aims to add support to the ISP CCDC driver to process interlaced video data in ITU-R BT.656 format.
The patch-set contains the following patches:
[PATCH 1/2] omap3isp: video: Decouple buffer obtaining and set ISP entities format [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
The first patch decouples next frame buffer obtaining from the last frame buffer releasing. This change is needed by the second patch that moves most of the CCDC buffer management logic to the VD1 interrupt handler.
This patch-set is a proof-of-concept and was only compile tested since I don't have the hardware to test right now. It is a forward porting, on top of Laurent's omap3isp-omap3isp-yuv tree, of the changes we made to the ISP driver to get interlaced video working.
Also, the patch will brake other configurations since the resizer and previewer also make use of omap3isp_video_buffer() function that now has a different semantic.
I'm posting even when the patch-set is not in a merge-able state so you can review what we were doing and make comments.
These are not all our changes since we also modified the ISP to forward the [G | S]_FMT and [G | S]_STD V4L2 ioctl commands to the TVP5151 and to only copy the active lines, but those changes are not relevant with the ghosting effect. With these changes we could get the 25 fps but with some sort of artifacts on the images.
I hope that together we can find a solution to this issue.
Thanks a lot.
PATCH 1/2 omap3isp: video: Decouple buffer obtaining and set ISP entities format
The ISP driver release the last buffer (waking up the pending process) before returning the next buffer to the caller. This is done on the VD0 interrupt handler. But, by the time the CCDC is executing the VD0 interrupt handler some ISP registers like CCDC_SDR_ADDR are shadowed which means that the values written to it will not take effect until the next frame starts.
We have to configure the CCDC during the processing of the current frame in the VD1 interrupt handler. This means the next buffer obtaining and the last buffer releasing occur at different moments. So we have to decouple these two actions.
--- drivers/media/video/omap3isp/ispvideo.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/media/video/omap3isp/ispvideo.c +0 -4
@@ -635,10 +635,6 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video,else buf->vbuf.sequence =atomic_read (&pipe->frame_number); - buf->state = error ?ISP_BUF_STATE_ERROR :ISP_BUF_STATE_DONE ; - -wake_up (&buf->wait); -if (list_empty (&video->dmaqueue)) {if (queue->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE ) state =ISP_PIPELINE_QUEUE_OUTPUT
Signature · 1 line
1.7.4.1
PATCH 2/2 omap3isp: ccdc: Add support to ITU-R BT.656 video data format
In reply to Javier Martinez CanillasThe ITU-R BT.656 standard data format provides interlaced video data.
This patch adds to the ISP CCDC driver the ability to deinterlace the video data and send progressive frames to user-space applications.
The changes are:
- Maintain two buffers (struct isp_buffer), current and last.
- Decouple next buffer obtaining from last buffer releasing.
- Move most of the logic to the VD1 interrupt handler since the ISP is not busy there.
--- drivers/media/video/omap3isp/ispccdc.c | 195 ++++++++++++++++++++++---------- drivers/media/video/omap3isp/ispccdc.h | 6 + include/media/omap3isp.h | 3 + 3 files changed, 146 insertions(+), 58 deletions(-)
drivers/media/video/omap3isp/ispccdc.c +137 -58
@@ -40,6 +40,7 @@static struct v4l2_mbus_framefmt *__ccdc_get_format (struct isp_ccdc_device *ccdc,struct v4l2_subdev_fh *fh,unsigned int pad,enum v4l2_subdev_format_whence which); +static bool ccdc_input_is_bt656 (struct isp_ccdc_device *ccdc);static const unsigned int ccdc_fmts[] = {V4L2_MBUS_FMT_Y8_1X8 ,
@@ -893,7 +894,7 @@ static void ccdc_config_outlineoffset(struct isp_ccdc_device *ccdc, ISPCCDC_SDOFST_FINV);isp_reg_clr (isp,OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_SDOFST , -ISPCCDC_SDOFST_FOFST_4L ); +ISPCCDC_SDOFST_FOFST_1L );switch (oddeven) {case EVENEVEN :
@@ -1010,6 +1011,9 @@ static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc,if (pdata && pdata->vs_pol) syn_mode |=ISPCCDC_SYN_MODE_VDPOL ; +if (pdata && pdata->fldmode) + syn_mode |=ISPCCDC_SYN_MODE_FLDMODE ; +isp_reg_writel (isp, syn_mode,OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_SYN_MODE );if (format->code ==V4L2_MBUS_FMT_UYVY8_2X8 )
@@ -1115,6 +1119,10 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)unsigned int shift;u32 syn_mode;u32 ccdc_pattern; +u32 nph; +u32 nlv; +u32 vd0; +u32 vd1; pad =media_entity_remote_source (&ccdc->pads[CCDC_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity);
@@ -1185,26 +1193,44 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) }ccdc_config_imgattr (ccdc, ccdc_pattern); +if (pdata->bt656) { + vd0 = nlv = format->height /2 -1 ; + vd1 = format->height /3 -1 ; + nph = format->width *2 -1 ; + }else { + vd0 = nlv = format->height -2 ; + vd1 = format->height *2 /3 ; + nph = format->width -1 ; + } +/* Generate VD0 on the last line of the image and VD1 on the * 2/3 height line. */ -isp_reg_writel (isp, ((format->height -2 ) <<ISPCCDC_VDINT_0_SHIFT ) | - ((format->height *2 /3 ) <<ISPCCDC_VDINT_1_SHIFT ), +isp_reg_writel (isp, (vd0 <<ISPCCDC_VDINT_0_SHIFT ) | + (vd1 <<ISPCCDC_VDINT_1_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VDINT );/* CCDC_PAD_SOURCE_OF */ format = &ccdc->formats[CCDC_PAD_SOURCE_OF ];isp_reg_writel (isp, (0 <<ISPCCDC_HORZ_INFO_SPH_SHIFT ) | - ((format->width -1 ) <<ISPCCDC_HORZ_INFO_NPH_SHIFT ), + (nph <<ISPCCDC_HORZ_INFO_NPH_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_HORZ_INFO ); +isp_reg_writel (isp, nlv <<ISPCCDC_VERT_LINES_NLV_SHIFT , +OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_LINES );isp_reg_writel (isp,0 <<ISPCCDC_VERT_START_SLV0_SHIFT ,OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_START ); -isp_reg_writel (isp, (format->height -1 ) - <<ISPCCDC_VERT_LINES_NLV_SHIFT , -OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_LINES ); +isp_reg_writel (isp,0 <<ISPCCDC_VERT_START_SLV1_SHIFT , +OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_START ); -ccdc_config_outlineoffset (ccdc, ccdc->video_out.bpl_value,0 ,0 ); + +if (pdata->bt656) { +ccdc_config_outlineoffset (ccdc, nph,EVENEVEN ,1 ); +ccdc_config_outlineoffset (ccdc, nph,EVENODD ,1 ); +ccdc_config_outlineoffset (ccdc, nph,ODDEVEN ,1 ); +ccdc_config_outlineoffset (ccdc, nph,ODDODD ,1 ); + }else +ccdc_config_outlineoffset (ccdc, ccdc->video_out.bpl_value,0 ,0 );/* CCDC_PAD_SOURCE_VP */ format = &ccdc->formats[CCDC_PAD_SOURCE_VP ];
@@ -1212,13 +1238,12 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)isp_reg_writel (isp, (0 <<ISPCCDC_FMT_HORZ_FMTSPH_SHIFT ) | (format->width <<ISPCCDC_FMT_HORZ_FMTLNH_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_FMT_HORZ ); -isp_reg_writel (isp, (0 <<ISPCCDC_FMT_VERT_FMTSLV_SHIFT ) | - ((format->height +1 ) <<ISPCCDC_FMT_VERT_FMTLNV_SHIFT ), -OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_FMT_VERT ); -isp_reg_writel (isp, (format->width <<ISPCCDC_VP_OUT_HORZ_NUM_SHIFT ) | (format->height <<ISPCCDC_VP_OUT_VERT_NUM_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VP_OUT ); +isp_reg_writel (isp, (0 <<ISPCCDC_FMT_VERT_FMTSLV_SHIFT ) | + ((format->height +1 ) <<ISPCCDC_FMT_VERT_FMTLNV_SHIFT ), +OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_FMT_VERT );/* Use PACK8 mode for 1byte per pixel formats. */ if (omap3isp_video_format_info (format->code)->width <=8 )
@@ -1464,6 +1489,19 @@ done:spin_unlock_irqrestore (&ccdc->lsc.req_lock, flags); } +static void ccdc_release_buffer (struct isp_buffer *buffer,int error) +{ + buffer->buffer.state = error ?ISP_BUF_STATE_ERROR :ISP_BUF_STATE_DONE ; +wake_up (&buffer->buffer.wait); +} + +static void ccdc_release_last_buffer (struct isp_ccdc_device *ccdc) +{ +struct isp_buffer *buffer = ccdc->last_buffer; + ccdc->last_buffer =NULL ; +ccdc_release_buffer (buffer, ccdc->error); +} +static int ccdc_isr_buffer (struct isp_ccdc_device *ccdc) {struct isp_pipeline *pipe =to_isp_pipeline (&ccdc->subdev.entity);
@@ -1495,11 +1533,19 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc) goto done; } - buffer =omap3isp_video_buffer_next (&ccdc->video_out, ccdc->error); -if (buffer !=NULL ) { -ccdc_set_outaddr (ccdc, buffer->isp_addr); +if (!ccdc_input_is_bt656 (ccdc)) { + ccdc->last_buffer = ccdc->current_buffer; + buffer =omap3isp_video_buffer_next (&ccdc->video_out, + ccdc->error); +if (buffer !=NULL ) { +ccdc_set_outaddr (ccdc, buffer->isp_addr); + restart =1 ; + } + ccdc->current_buffer = buffer; +if (ccdc->last_buffer) +ccdc_release_last_buffer (ccdc); + }else restart =1 ; - } pipe->state |=ISP_PIPELINE_IDLE_OUTPUT ;
@@ -1541,6 +1587,16 @@ static void ccdc_vd0_isr(struct isp_ccdc_device *ccdc)ccdc_enable (ccdc); } +static inline struct isp_buffer *ccdc_getbuffer (struct isp_ccdc_device *ccdc) +{ +return omap3isp_video_buffer_next (&ccdc->video_out, ccdc->error); +} + +static inline void ccdc_set_next_buffer (struct isp_ccdc_device *ccdc) +{ +ccdc_set_outaddr (ccdc, ccdc->current_buffer->isp_addr); +} +/* * ccdc_vd1_isr - Handle VD1 event * @ccdc: Pointer to ISP CCDC device.
@@ -1549,57 +1605,77 @@ static void ccdc_vd1_isr(struct isp_ccdc_device *ccdc) {unsigned long flags; -spin_lock_irqsave (&ccdc->lsc.req_lock, flags); +if (ccdc_input_is_bt656 (ccdc)) { +if (ccdc->interlaced_cnt) { + ccdc->interlaced_cnt =0 ; + ccdc->last_buffer = ccdc->current_buffer; +if (!list_empty (&ccdc->video_out.dmaqueue)) { + ccdc->current_buffer = +ccdc_getbuffer (ccdc); +if (ccdc->current_buffer !=NULL ) +ccdc_set_next_buffer (ccdc); + }else + ccdc->current_buffer =NULL ; + }else { + ccdc->interlaced_cnt =1 ; +if (ccdc->last_buffer) +ccdc_release_last_buffer (ccdc); + } + }else { -/* -* Depending on the CCDC pipeline state, CCDC stopping should be -* handled differently. In SINGLESHOT we emulate an internal CCDC -* stopping because the CCDC hw works only in continuous mode. -* When CONTINUOUS pipeline state is used and the CCDC writes it's -* data to memory the CCDC and LSC are stopped immediately but -* without change the CCDC stopping state machine. The CCDC -* stopping state machine should be used only when user request -* for stopping is received (SINGLESHOT is an exeption). -*/ -switch (ccdc->state) { -case ISP_PIPELINE_STREAM_SINGLESHOT : - ccdc->stopping =CCDC_STOP_REQUEST ; -break ; +spin_lock_irqsave (&ccdc->lsc.req_lock, flags); -case ISP_PIPELINE_STREAM_CONTINUOUS : -if (ccdc->output &CCDC_OUTPUT_MEMORY ) { -if (ccdc->lsc.state !=LSC_STATE_STOPPED ) -__ccdc_lsc_enable (ccdc,0 ); -__ccdc_enable (ccdc,0 ); - } -break ; +/* +* Depending on the CCDC pipeline state, CCDC stopping should be +* handled differently. In SINGLESHOT we emulate an internal CCDC +* stopping because the CCDC hw works only in continuous mode. +* When CONTINUOUS pipeline state is used and the CCDC writes it's +* data to memory the CCDC and LSC are stopped immediately but +* without change the CCDC stopping state machine. The CCDC +* stopping state machine should be used only when user request +* for stopping is received (SINGLESHOT is an exeption). +*/ +switch (ccdc->state) { +case ISP_PIPELINE_STREAM_SINGLESHOT : + ccdc->stopping =CCDC_STOP_REQUEST ; +break ; -case ISP_PIPELINE_STREAM_STOPPED : -break ; - } +case ISP_PIPELINE_STREAM_CONTINUOUS : +if (ccdc->output &CCDC_OUTPUT_MEMORY ) { +if (ccdc->lsc.state !=LSC_STATE_STOPPED ) +__ccdc_lsc_enable (ccdc,0 ); +__ccdc_enable (ccdc,0 ); + } +break ; -if (__ccdc_handle_stopping (ccdc,CCDC_EVENT_VD1 )) - goto done; +case ISP_PIPELINE_STREAM_STOPPED : +break ; + } -if (ccdc->lsc.request ==NULL ) - goto done; +if (__ccdc_handle_stopping (ccdc,CCDC_EVENT_VD1 )) + goto done; -/* -* LSC need to be reconfigured. Stop it here and on next LSC_DONE IRQ -* do the appropriate changes in registers -*/ -if (ccdc->lsc.state ==LSC_STATE_RUNNING ) { -__ccdc_lsc_enable (ccdc,0 ); - ccdc->lsc.state =LSC_STATE_RECONFIG ; - goto done; - } +if (ccdc->lsc.request ==NULL ) + goto done; -/* LSC has been in STOPPED state, enable it */ -if (ccdc->lsc.state ==LSC_STATE_STOPPED ) -ccdc_lsc_enable (ccdc); +/* +* LSC need to be reconfigured. Stop it here and on next +* LSC_DONE IRQ do the appropriate changes in registers +*/ +if (ccdc->lsc.state ==LSC_STATE_RUNNING ) { +__ccdc_lsc_enable (ccdc,0 ); + ccdc->lsc.state =LSC_STATE_RECONFIG ; + goto done; + } + +/* LSC has been in STOPPED state, enable it */ +if (ccdc->lsc.state ==LSC_STATE_STOPPED ) +ccdc_lsc_enable (ccdc); done: -spin_unlock_irqrestore (&ccdc->lsc.req_lock, flags); +spin_unlock_irqrestore (&ccdc->lsc.req_lock, flags); + + } }/*
@@ -1638,6 +1714,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer)return -ENODEV ;ccdc_set_outaddr (ccdc, buffer->isp_addr); + ccdc->current_buffer = buffer;/* We now have a buffer queued on the output, restart the pipeline * on the next CCDC interrupt if running in continuous mode (or when
@@ -1764,6 +1841,8 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable)omap3isp_sbl_disable (isp,OMAP3_ISP_SBL_CCDC_WRITE );omap3isp_subclk_disable (isp,OMAP3_ISP_SUBCLK_CCDC ); ccdc->underrun =0 ; + ccdc->current_buffer =NULL ; + ccdc->interlaced_cnt =0 ;break ; }
drivers/media/video/omap3isp/ispccdc.h +6 -0
@@ -134,6 +134,9 @@ struct ispccdc_lsc {* @wait: Wait queue used to stop the module * @stopping: Stopping state * @ioctl_lock: Serializes ioctl calls and LSC requests freeing +* @current_buffer: Buffer for current frame +* @last_buffer: Buffer used for the last frame +* @interlaced_cnt: Sub-frame count for an interlaced video frame */ struct isp_ccdc_device {struct v4l2_subdev subdev;
@@ -164,6 +167,9 @@ struct isp_ccdc_device {wait_queue_head_t wait;unsigned int stopping;struct mutex ioctl_lock; +struct isp_buffer *current_buffer; +struct isp_buffer *last_buffer; +unsigned int interlaced_cnt; };struct isp_device ;
include/media/omap3isp.h +3 -0
@@ -61,6 +61,8 @@ enum {* 0 - Normal, 1 - One's complement * @bt656: ITU-R BT656 embedded synchronization * 0 - HS/VS sync, 1 - BT656 sync +* @fldmode: Field mode +* 0 - progressive, 1 - Interlaced */ struct isp_parallel_platform_data {unsigned int data_lane_shift:2 ;
@@ -69,6 +71,7 @@ struct isp_parallel_platform_data { unsigned int vs_pol:1; unsigned int data_pol:1; unsigned int bt656:1; + unsigned int fldmode:1; };enum {
Signature · 1 line
1.7.4.1
Re: [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
Hi Javier,
Thanks for the patch.
Quoted 10 lines · On Sunday 09 October 2011 04:37:33 Javier Martinez Canillas wrote:
The ITU-R BT.656 standard data format provides interlaced video data.
This patch adds to the ISP CCDC driver the ability to deinterlace the video data and send progressive frames to user-space applications.
The changes are:
- Maintain two buffers (structisp_buffer), current and last.
- Decouple next buffer obtaining from last buffer releasing.
- Move most of the logic to the VD1 interrupt handler since the ISP is not busy there.
Could you please explain why this is needed ?
Quoted 21 lines
Signed-off-by Javier Martinez Canillas <[email protected]>--- drivers/media/video/omap3isp/ispccdc.c | 195 ++++++++++++++++++++++---------- drivers/media/video/omap3isp/ispccdc.h | 6 + include/media/omap3isp.h | 3 + 3 files changed, 146 insertions(+), 58 deletions(-)(quoted diff) +0
-0
b/drivers/media/video/omap3isp/ispccdc.cindex c25db54..fff1ae1 100644drivers/media/video/omap3isp/ispccdc.c +1
-0@@ -40,6 +40,7 @@static struct v4l2_mbus_framefmt *__ccdc_get_format (struct isp_ccdc_device *ccdc,struct v4l2_subdev_fh *fh,unsigned int pad,enum v4l2_subdev_format_whence which); +static bool ccdc_input_is_bt656 (struct isp_ccdc_device *ccdc);static const unsigned int ccdc_fmts[] = {V4L2_MBUS_FMT_Y8_1X8 ,
drivers/media/video/omap3isp/ispccdc.c static void ccdc_config_outlineoffset(struct · line 897
Quoted 5 lines
drivers/media/video/omap3isp/ispccdc.c +1
-1@@ -893,7 +894,7 @@ static void ccdc_config_outlineoffset(struct isp_ccdc_device *ccdc, ISPCCDC_SDOFST_FINV);isp_reg_clr (isp,OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_SDOFST , -ISPCCDC_SDOFST_FOFST_4L ); +ISPCCDC_SDOFST_FOFST_1L );
Are you sure this is needed ? isp_reg_clr() clears the bits (which are as far as I see not set anyway).
drivers/media/video/omap3isp/ispccdc.c static void ccdc_config_sync_if(struct · line 1016
Quoted 9 lines
drivers/media/video/omap3isp/ispccdc.c +3
-0switch (oddeven) {case EVENEVEN :@@ -1010,6 +1011,9 @@ static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc, if (pdata && pdata->vs_pol) syn_mode |= ISPCCDC_SYN_MODE_VDPOL; +if (pdata && pdata->fldmode) + syn_mode |=ISPCCDC_SYN_MODE_FLDMODE ; +
Addition and usage of the fldmode field can be split to a patch of its own.
Quoted 15 lines
drivers/media/video/omap3isp/ispccdc.c +4
-0isp_reg_writel (isp, syn_mode,OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_SYN_MODE );if (format->code ==V4L2_MBUS_FMT_UYVY8_2X8 )@@ -1115,6 +1119,10 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) unsigned int shift;u32 syn_mode;u32 ccdc_pattern; +u32 nph; +u32 nlv; +u32 vd0; +u32 vd1; pad =media_entity_remote_source (&ccdc->pads[CCDC_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity);
drivers/media/video/omap3isp/ispccdc.c static void ccdc_configure(struct isp_ccdc_device · line 1199
Quoted 7 lines
drivers/media/video/omap3isp/ispccdc.c +4
-0@@ -1185,26 +1193,44 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) }ccdc_config_imgattr (ccdc, ccdc_pattern); +if (pdata->bt656) { + vd0 = nlv = format->height /2 -1 ; + vd1 = format->height /3 -1 ; + nph = format->width *2 -1 ;
Isn't this applicable to interlaced non-BT.656 modes as well ? Same for the other bt656 checks you introduce below.
Quoted 133 lines
drivers/media/video/omap3isp/ispccdc.c +64
-16+ }else { + vd0 = nlv = format->height -2 ; + vd1 = format->height *2 /3 ; + nph = format->width -1 ; + } +/* Generate VD0 on the last line of the image and VD1 on the * 2/3 height line. */ -isp_reg_writel (isp, ((format->height -2 ) <<ISPCCDC_VDINT_0_SHIFT ) | - ((format->height *2 /3 ) <<ISPCCDC_VDINT_1_SHIFT ), +isp_reg_writel (isp, (vd0 <<ISPCCDC_VDINT_0_SHIFT ) | + (vd1 <<ISPCCDC_VDINT_1_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VDINT );/* CCDC_PAD_SOURCE_OF */ format = &ccdc->formats[CCDC_PAD_SOURCE_OF ];isp_reg_writel (isp, (0 <<ISPCCDC_HORZ_INFO_SPH_SHIFT ) | - ((format->width -1 ) <<ISPCCDC_HORZ_INFO_NPH_SHIFT ), + (nph <<ISPCCDC_HORZ_INFO_NPH_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_HORZ_INFO ); +isp_reg_writel (isp, nlv <<ISPCCDC_VERT_LINES_NLV_SHIFT , +OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_LINES );isp_reg_writel (isp,0 <<ISPCCDC_VERT_START_SLV0_SHIFT ,OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_START ); -isp_reg_writel (isp, (format->height -1 ) - <<ISPCCDC_VERT_LINES_NLV_SHIFT , -OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_LINES ); +isp_reg_writel (isp,0 <<ISPCCDC_VERT_START_SLV1_SHIFT , +OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VERT_START ); -ccdc_config_outlineoffset (ccdc, ccdc->video_out.bpl_value,0 ,0 ); + +if (pdata->bt656) { +ccdc_config_outlineoffset (ccdc, nph,EVENEVEN ,1 ); +ccdc_config_outlineoffset (ccdc, nph,EVENODD ,1 ); +ccdc_config_outlineoffset (ccdc, nph,ODDEVEN ,1 ); +ccdc_config_outlineoffset (ccdc, nph,ODDODD ,1 ); + }else +ccdc_config_outlineoffset (ccdc, ccdc->video_out.bpl_value,0 ,0 );/* CCDC_PAD_SOURCE_VP */ format = &ccdc->formats[CCDC_PAD_SOURCE_VP ];@@ -1212,13 +1238,12 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) isp_reg_writel(isp, (0 << ISPCCDC_FMT_HORZ_FMTSPH_SHIFT) | (format->width <<ISPCCDC_FMT_HORZ_FMTLNH_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_FMT_HORZ ); -isp_reg_writel (isp, (0 <<ISPCCDC_FMT_VERT_FMTSLV_SHIFT ) | - ((format->height +1 ) <<ISPCCDC_FMT_VERT_FMTLNV_SHIFT ), -OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_FMT_VERT ); -isp_reg_writel (isp, (format->width <<ISPCCDC_VP_OUT_HORZ_NUM_SHIFT ) | (format->height <<ISPCCDC_VP_OUT_VERT_NUM_SHIFT ),OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_VP_OUT ); +isp_reg_writel (isp, (0 <<ISPCCDC_FMT_VERT_FMTSLV_SHIFT ) | + ((format->height +1 ) <<ISPCCDC_FMT_VERT_FMTLNV_SHIFT ), +OMAP3_ISP_IOMEM_CCDC ,ISPCCDC_FMT_VERT );/* Use PACK8 mode for 1byte per pixel formats. */ if (omap3isp_video_format_info (format->code)->width <=8 )@@ -1464,6 +1489,19 @@ done:spin_unlock_irqrestore (&ccdc->lsc.req_lock, flags); } +static void ccdc_release_buffer (struct isp_buffer *buffer,int error) +{ + buffer->buffer.state = error ?ISP_BUF_STATE_ERROR :ISP_BUF_STATE_DONE ; +wake_up (&buffer->buffer.wait); +} + +static void ccdc_release_last_buffer (struct isp_ccdc_device *ccdc) +{ +struct isp_buffer *buffer = ccdc->last_buffer; + ccdc->last_buffer =NULL ; +ccdc_release_buffer (buffer, ccdc->error); +} +static int ccdc_isr_buffer (struct isp_ccdc_device *ccdc) {struct isp_pipeline *pipe =to_isp_pipeline (&ccdc->subdev.entity);@@ -1495,11 +1533,19 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc) goto done; } - buffer =omap3isp_video_buffer_next (&ccdc->video_out, ccdc->error); -if (buffer !=NULL ) { -ccdc_set_outaddr (ccdc, buffer->isp_addr); +if (!ccdc_input_is_bt656 (ccdc)) { + ccdc->last_buffer = ccdc->current_buffer; + buffer =omap3isp_video_buffer_next (&ccdc->video_out, + ccdc->error); +if (buffer !=NULL ) { +ccdc_set_outaddr (ccdc, buffer->isp_addr); + restart =1 ; + } + ccdc->current_buffer = buffer; +if (ccdc->last_buffer) +ccdc_release_last_buffer (ccdc); + }else restart =1 ; - } pipe->state |=ISP_PIPELINE_IDLE_OUTPUT ;@@ -1541,6 +1587,16 @@ static void ccdc_vd0_isr(struct isp_ccdc_device *ccdc) ccdc_enable(ccdc); } +static inline struct isp_buffer *ccdc_getbuffer (struct isp_ccdc_device *ccdc) +{ +return omap3isp_video_buffer_next (&ccdc->video_out, ccdc->error); +} + +static inline void ccdc_set_next_buffer (struct isp_ccdc_device *ccdc) +{ +ccdc_set_outaddr (ccdc, ccdc->current_buffer->isp_addr); +} +/* * ccdc_vd1_isr - Handle VD1 event * @ccdc: Pointer to ISP CCDC device. @@ -1549,57 +1605,77 @@ static void ccdc_vd1_isr(struct isp_ccdc_device *ccdc) {unsigned long flags; -spin_lock_irqsave (&ccdc->lsc.req_lock, flags); +if (ccdc_input_is_bt656 (ccdc)) { +if (ccdc->interlaced_cnt) { + ccdc->interlaced_cnt =0 ; + ccdc->last_buffer = ccdc->current_buffer; +if (!list_empty (&ccdc->video_out.dmaqueue)) { + ccdc->current_buffer =
drivers/media/video/omap3isp/ispccdc.c static void ccdc_vd1_isr(struct isp_ccdc_device · line 1623
Quoted 10 lines
drivers/media/video/omap3isp/ispccdc.c +10
-0+ccdc_getbuffer (ccdc); +if (ccdc->current_buffer !=NULL ) +ccdc_set_next_buffer (ccdc); + }else + ccdc->current_buffer =NULL ; + }else { + ccdc->interlaced_cnt =1 ; +if (ccdc->last_buffer) +ccdc_release_last_buffer (ccdc); + }
Please add a return; here, it will avoid the else below and will make the code easier to review.
Quoted 140 lines
drivers/media/video/omap3isp/ispccdc.c +49
-41+ }else { -/* -* Depending on the CCDC pipeline state, CCDC stopping should be -* handled differently. In SINGLESHOT we emulate an internal CCDC -* stopping because the CCDC hw works only in continuous mode. -* When CONTINUOUS pipeline state is used and the CCDC writes it's -* data to memory the CCDC and LSC are stopped immediately but -* without change the CCDC stopping state machine. The CCDC -* stopping state machine should be used only when user request -* for stopping is received (SINGLESHOT is an exeption). -*/ -switch (ccdc->state) { -case ISP_PIPELINE_STREAM_SINGLESHOT : - ccdc->stopping =CCDC_STOP_REQUEST ; -break ; +spin_lock_irqsave (&ccdc->lsc.req_lock, flags); -case ISP_PIPELINE_STREAM_CONTINUOUS : -if (ccdc->output &CCDC_OUTPUT_MEMORY ) { -if (ccdc->lsc.state !=LSC_STATE_STOPPED ) -__ccdc_lsc_enable (ccdc,0 ); -__ccdc_enable (ccdc,0 ); - } -break ; +/* +* Depending on the CCDC pipeline state, CCDC stopping should be +* handled differently. In SINGLESHOT we emulate an internal CCDC +* stopping because the CCDC hw works only in continuous mode. +* When CONTINUOUS pipeline state is used and the CCDC writes it's +* data to memory the CCDC and LSC are stopped immediately but +* without change the CCDC stopping state machine. The CCDC +* stopping state machine should be used only when user request +* for stopping is received (SINGLESHOT is an exeption). +*/ +switch (ccdc->state) { +case ISP_PIPELINE_STREAM_SINGLESHOT : + ccdc->stopping =CCDC_STOP_REQUEST ; +break ; -case ISP_PIPELINE_STREAM_STOPPED : -break ; - } +case ISP_PIPELINE_STREAM_CONTINUOUS : +if (ccdc->output &CCDC_OUTPUT_MEMORY ) { +if (ccdc->lsc.state !=LSC_STATE_STOPPED ) +__ccdc_lsc_enable (ccdc,0 ); +__ccdc_enable (ccdc,0 ); + } +break ; -if (__ccdc_handle_stopping (ccdc,CCDC_EVENT_VD1 )) - goto done; +case ISP_PIPELINE_STREAM_STOPPED : +break ; + } -if (ccdc->lsc.request ==NULL ) - goto done; +if (__ccdc_handle_stopping (ccdc,CCDC_EVENT_VD1 )) + goto done; -/* -* LSC need to be reconfigured. Stop it here and on next LSC_DONE IRQ -* do the appropriate changes in registers -*/ -if (ccdc->lsc.state ==LSC_STATE_RUNNING ) { -__ccdc_lsc_enable (ccdc,0 ); - ccdc->lsc.state =LSC_STATE_RECONFIG ; - goto done; - } +if (ccdc->lsc.request ==NULL ) + goto done; -/* LSC has been in STOPPED state, enable it */ -if (ccdc->lsc.state ==LSC_STATE_STOPPED ) -ccdc_lsc_enable (ccdc); +/* +* LSC need to be reconfigured. Stop it here and on next +* LSC_DONE IRQ do the appropriate changes in registers +*/ +if (ccdc->lsc.state ==LSC_STATE_RUNNING ) { +__ccdc_lsc_enable (ccdc,0 ); + ccdc->lsc.state =LSC_STATE_RECONFIG ; + goto done; + } + +/* LSC has been in STOPPED state, enable it */ +if (ccdc->lsc.state ==LSC_STATE_STOPPED ) +ccdc_lsc_enable (ccdc); done: -spin_unlock_irqrestore (&ccdc->lsc.req_lock, flags); +spin_unlock_irqrestore (&ccdc->lsc.req_lock, flags); + + } }/* @@ -1638,6 +1714,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer) return -ENODEV;ccdc_set_outaddr (ccdc, buffer->isp_addr); + ccdc->current_buffer = buffer;/* We now have a buffer queued on the output, restart the pipeline * on the next CCDC interrupt if running in continuous mode (or when @@ -1764,6 +1841,8 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable) omap3isp_sbl_disable(isp, OMAP3_ISP_SBL_CCDC_WRITE);omap3isp_subclk_disable (isp,OMAP3_ISP_SUBCLK_CCDC ); ccdc->underrun =0 ; + ccdc->current_buffer =NULL ; + ccdc->interlaced_cnt =0 ;break ; }(quoted diff) +0
-0
b/drivers/media/video/omap3isp/ispccdc.hindex 54811ce..dad021c 100644drivers/media/video/omap3isp/ispccdc.h +6
-0@@ -134,6 +134,9 @@ struct ispccdc_lsc {* @wait: Wait queue used to stop the module * @stopping: Stopping state * @ioctl_lock: Serializes ioctl calls and LSC requests freeing +* @current_buffer: Buffer for current frame +* @last_buffer: Buffer used for the last frame +* @interlaced_cnt: Sub-frame count for an interlaced video frame */ struct isp_ccdc_device {struct v4l2_subdev subdev;@@ -164,6 +167,9 @@ struct isp_ccdc_device {wait_queue_head_t wait;unsigned int stopping;struct mutex ioctl_lock; +struct isp_buffer *current_buffer; +struct isp_buffer *last_buffer; +unsigned int interlaced_cnt; };struct isp_device ;
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
Quoted 4 lines · Laurent Pinchart
Hi Javier,
Thanks for the patch.
Hi Laurent, I'm so glad that you are providing feedback on this :)
Quoted 6 lines · On Sunday 09 October 2011 04:37:33 Javier Martinez Canillas wrote:
Quoted 5 lines
The ITU-R BT.656 standard data format provides interlaced video data.
This patch adds to the ISP CCDC driver the ability to deinterlace the video data and send progressive frames to user-space applications.
Quoted 8 lines
Quoted 5 lines
The changes are:
- Maintain two buffers (structisp_buffer), current and last.
- Decouple next buffer obtaining from last buffer releasing.
- Move most of the logic to the VD1 interrupt handler since the ISP is not busy there.Could you please explain why this is needed ?
Well, reading the TRM I came to the conclusion (I may be wrong with this assumption) that it is not correct to do the buffer management for the CCDC on the VD0 interrupt handler. Since by the time you are processing the end of frame interrupt handler a new frame has already started.
The ISP shadowed registers values can't be updated there because the values written to them will not take effect until the start of the next frame. But since a new frame has already started, by the time we are setting for example the CCDC_SDR_ADDR register, this means that the frame already being processed will use the last value and not the one we expect it to use.
For me, made more sense to move all the buffer management code to the VD1 interrupt handler. Since this occurs before a frame ends, if we update there the shadowed registers, the values will take effect when the next frame starts.
But you can't release the las buffer yet, since the ISP is still processing the frame and copying to memory. We have to release the last buffer (and wake the pending process) either on the VD0 handler when the frame processing finish or during the VD1 handler when the next frame has already started.
This means that the next buffer obtaining and the last buffer releasing occur at different moment. So, we have to decouple these two actions.
I hope I made myself clear with this. Am I right or completely lost with this?
Quoted 23 lines
Quoted 23 lines
Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/media/video/omap3isp/ispccdc.c | 195 ++++++++++++++++++++++----------drivers/media/video/omap3isp/ispccdc.h| 6 +
include/media/omap3isp.h | 3 +3 files changed, 146 insertions(+), 58 deletions(-)(quoted diff) +0
-0
b/drivers/media/video/omap3isp/ispccdc.cindex c25db54..fff1ae1 100644drivers/media/video/omap3isp/ispccdc.c +0
-0@@ -40,6 +40,7 @@static struct
v4l2_mbus_framefmt*
__ccdc_get_format(structisp_ccdc_device*ccdc, structv4l2_subdev_fh*fh, unsigned int pad, enumv4l2_subdev_format_whencewhich); +static boolccdc_input_is_bt656(struct isp_ccdc_device *ccdc);static const unsigned int ccdc_fmts[] = {
V4L2_MBUS_FMT_Y8_1X8,drivers/media/video/omap3isp/ispccdc.c +0
-0@@ -893,7 +894,7 @@ static void ccdc_config_outlineoffset(struct isp_ccdc_device *ccdc, ISPCCDC_SDOFST_FINV);
Quoted 7 lines
drivers/media/video/omap3isp/ispccdc.c static void ccdc_config_outlineoffset(struct isp_ccdc_device *ccdc, · line 897
Quoted 3 lines
drivers/media/video/omap3isp/ispccdc.c +1
-1isp_reg_clr(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SDOFST, - ISPCCDC_SDOFST_FOFST_4L); + ISPCCDC_SDOFST_FOFST_1L);Are you sure this is needed ?
isp_reg_clr()clears the bits (which are as far as I see not set anyway).
The value 0x0 on the FOFST field configures the line offset value to +1. But looking at the TRM now this is the default value so you are right, this is not needed and I'll remove it.
Quoted 6 lines
Quoted 6 lines
drivers/media/video/omap3isp/ispccdc.c +0
-0switch (oddeven) {case EVENEVEN:
drivers/media/video/omap3isp/ispccdc.c +0
-0@@ -1010,6 +1011,9 @@ static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc, if (pdata && pdata->vs_pol) syn_mode |= ISPCCDC_SYN_MODE_VDPOL;
Quoted 6 lines
drivers/media/video/omap3isp/ispccdc.c static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc, · line 1016
Quoted 3 lines
drivers/media/video/omap3isp/ispccdc.c +3
-0+ if (pdata && pdata->fldmode) + syn_mode |= ISPCCDC_SYN_MODE_FLDMODE; +Addition and usage of the fldmode field can be split to a patch of its own.
Ok, will do.
Quoted 18 lines
Quoted 18 lines
drivers/media/video/omap3isp/ispccdc.c +4
-0isp_reg_writel(isp, syn_mode, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SYN_MODE); if (format->code == V4L2_MBUS_FMT_UYVY8_2X8)@@ -1115,6 +1119,10 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) unsigned int shift; u32 syn_mode; u32 ccdc_pattern; + u32 nph; + u32 nlv; + u32 vd0; + u32 vd1; pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); sensor = media_entity_to_v4l2_subdev(pad->entity);@@ -1185,26 +1193,44 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) } ccdc_config_imgattr(ccdc, ccdc_pattern);
Quoted 8 lines
drivers/media/video/omap3isp/ispccdc.c static void ccdc_configure(struct isp_ccdc_device *ccdc) · line 1199
Quoted 4 lines
drivers/media/video/omap3isp/ispccdc.c +4
-0+ if (pdata->bt656) { + vd0 = nlv = format->height / 2 - 1; + vd1 = format->height / 3 - 1; + nph = format->width * 2 - 1;Isn't this applicable to interlaced non-BT.656 modes as well ? Same for the other bt656 checks you introduce below.
You are right, I will check pdata->fldmode instead. The only one that is BT.656 specific is width * 2 since a pixel is represented with two bytes.
Quoted 138 lines
Quoted 138 lines
drivers/media/video/omap3isp/ispccdc.c +8
-2+ } else { + vd0 = nlv = format->height - 2; + vd1 = format->height * 2 / 3; + nph = format->width - 1; + } + /* Generate VD0 on the last line of the image and VD1 on the * 2/3 height line. */ - isp_reg_writel(isp, ((format->height - 2) << ISPCCDC_VDINT_0_SHIFT) | - ((format->height * 2 / 3) << ISPCCDC_VDINT_1_SHIFT), + isp_reg_writel(isp, (vd0 << ISPCCDC_VDINT_0_SHIFT) | + (vd1 << ISPCCDC_VDINT_1_SHIFT), OMAP3_ISP_IOMEM_CCDC, ISPCCDC_VDINT); /* CCDC_PAD_SOURCE_OF */ format = &ccdc->formats[CCDC_PAD_SOURCE_OF];isp_reg_writel(isp, (0 <<
ISPCCDC_HORZ_INFO_SPH_SHIFT) |
- ((format->width - 1) <<ISPCCDC_HORZ_INFO_NPH_SHIFT),
+ (nph <<ISPCCDC_HORZ_INFO_NPH_SHIFT),OMAP3_ISP_IOMEM_CCDC,ISPCCDC_HORZ_INFO);
+ isp_reg_writel(isp, nlv <<ISPCCDC_VERT_LINES_NLV_SHIFT,
+ OMAP3_ISP_IOMEM_CCDC,ISPCCDC_VERT_LINES);isp_reg_writel(isp, 0 << ISPCCDC_VERT_START_SLV0_SHIFT, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_VERT_START);
- isp_reg_writel(isp, (format->height- 1)
- <<ISPCCDC_VERT_LINES_NLV_SHIFT,
- OMAP3_ISP_IOMEM_CCDC,ISPCCDC_VERT_LINES);
+ isp_reg_writel(isp, 0 <<ISPCCDC_VERT_START_SLV1_SHIFT,
+ OMAP3_ISP_IOMEM_CCDC,ISPCCDC_VERT_START);-
ccdc_config_outlineoffset(ccdc, ccdc->video_out.bpl_value, 0, 0); +
+ if (pdata->bt656) {
+ccdc_config_outlineoffset(ccdc, nph, EVENEVEN, 1);
+ccdc_config_outlineoffset(ccdc, nph, EVENODD, 1);
+ccdc_config_outlineoffset(ccdc, nph, ODDEVEN, 1);
+ccdc_config_outlineoffset(ccdc, nph, ODDODD, 1);
+ } else
+ccdc_config_outlineoffset(ccdc, ccdc->video_out.bpl_value, 0, 0);/*
CCDC_PAD_SOURCE_VP*/
format = &ccdc->formats[CCDC_PAD_SOURCE_VP];drivers/media/video/omap3isp/ispccdc.c +0
-4@@ -1212,13 +1238,12 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) isp_reg_writel(isp, (0 << ISPCCDC_FMT_HORZ_FMTSPH_SHIFT) | (format->width << ISPCCDC_FMT_HORZ_FMTLNH_SHIFT), OMAP3_ISP_IOMEM_CCDC, ISPCCDC_FMT_HORZ); - isp_reg_writel(isp, (0 << ISPCCDC_FMT_VERT_FMTSLV_SHIFT) | - ((format->height + 1) << ISPCCDC_FMT_VERT_FMTLNV_SHIFT), - OMAP3_ISP_IOMEM_CCDC, ISPCCDC_FMT_VERT); -isp_reg_writel(isp, (
format->width<<ISPCCDC_VP_OUT_HORZ_NUM_SHIFT) | (format->height<<ISPCCDC_VP_OUT_VERT_NUM_SHIFT),OMAP3_ISP_IOMEM_CCDC,ISPCCDC_VP_OUT);
+ isp_reg_writel(isp, (0 <<ISPCCDC_FMT_VERT_FMTSLV_SHIFT) |
+ ((format->height + 1) <<ISPCCDC_FMT_VERT_FMTLNV_SHIFT),
+ OMAP3_ISP_IOMEM_CCDC,ISPCCDC_FMT_VERT);/* Use PACK8 mode for 1byte per pixel formats. */ if (omap3isp_video_format_info(format->code)->width <= 8)
drivers/media/video/omap3isp/ispccdc.c +34
-4@@ -1464,6 +1489,19 @@ done: spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); } +static void ccdc_release_buffer (struct isp_buffer *buffer,int error) +{ + buffer->buffer.state = error ? ISP_BUF_STATE_ERROR : ISP_BUF_STATE_DONE; + wake_up(&buffer->buffer.wait); +} + +static void ccdc_release_last_buffer (struct isp_ccdc_device *ccdc) +{ + struct isp_buffer *buffer = ccdc->last_buffer; + ccdc->last_buffer = NULL; + ccdc_release_buffer(buffer, ccdc->error); +} + static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc) { struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity);@@ -1495,11 +1533,19 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc) goto done; } - buffer = omap3isp_video_buffer_next(&ccdc->video_out, ccdc->error); - if (buffer != NULL) { - ccdc_set_outaddr(ccdc, buffer->isp_addr); + if (!ccdc_input_is_bt656(ccdc)) { + ccdc->last_buffer = ccdc->current_buffer; + buffer = omap3isp_video_buffer_next(&ccdc->video_out, + ccdc->error); + if (buffer != NULL) { + ccdc_set_outaddr(ccdc, buffer->isp_addr); + restart = 1; + } + ccdc->current_buffer = buffer; + if (ccdc->last_buffer) + ccdc_release_last_buffer(ccdc); + } else restart = 1; - } pipe->state |= ISP_PIPELINE_IDLE_OUTPUT;@@ -1541,6 +1587,16 @@ static void ccdc_vd0_isr(struct isp_ccdc_device *ccdc) ccdc_enable(ccdc); } +static inline struct isp_buffer *ccdc_getbuffer (struct isp_ccdc_device *ccdc) +{ + return omap3isp_video_buffer_next(&ccdc->video_out, ccdc->error); +} + +static inline void ccdc_set_next_buffer (struct isp_ccdc_device *ccdc) +{ + ccdc_set_outaddr(ccdc, ccdc->current_buffer->isp_addr); +} + /** ccdc_vd1_isr - Handle VD1 event * @ccdc: Pointer to ISP CCDC device.
drivers/media/video/omap3isp/ispccdc.c +11
-1@@ -1549,57 +1605,77 @@ static void ccdc_vd1_isr(struct isp_ccdc_device *ccdc) { unsigned long flags; - spin_lock_irqsave(&ccdc->lsc.req_lock, flags); + if (ccdc_input_is_bt656(ccdc)) { + if (ccdc->interlaced_cnt) { + ccdc->interlaced_cnt = 0; + ccdc->last_buffer = ccdc->current_buffer; + if (!list_empty(&ccdc->video_out.dmaqueue)) { + ccdc->current_buffer = + ccdc_getbuffer(ccdc); + if (ccdc->current_buffer != NULL) + ccdc_set_next_buffer(ccdc); + } else + ccdc->current_buffer = NULL;
Quoted 9 lines
drivers/media/video/omap3isp/ispccdc.c static void ccdc_vd1_isr(struct isp_ccdc_device *ccdc) · line 1623
Quoted 5 lines
drivers/media/video/omap3isp/ispccdc.c +5
-0+ } else { + ccdc->interlaced_cnt = 1; + if (ccdc->last_buffer) + ccdc_release_last_buffer(ccdc); + }Please add a return; here, it will avoid the else below and will make the code easier to review.
Indeed, I will.
Quoted 139 lines
Quoted 139 lines
drivers/media/video/omap3isp/ispccdc.c +43
-40+ } else { - /* - * Depending on the CCDC pipeline state, CCDC stopping should be - * handled differently. In SINGLESHOT we emulate an internal CCDC - * stopping because the CCDC hw works only in continuous mode. - * When CONTINUOUS pipeline state is used and the CCDC writes it's - * data to memory the CCDC and LSC are stopped immediately but - * without change the CCDC stopping state machine. The CCDC - * stopping state machine should be used only when user request - * for stopping is received (SINGLESHOT is an exeption). - */ - switch (ccdc->state) { - case ISP_PIPELINE_STREAM_SINGLESHOT: - ccdc->stopping = CCDC_STOP_REQUEST; - break; + spin_lock_irqsave(&ccdc->lsc.req_lock, flags); - case ISP_PIPELINE_STREAM_CONTINUOUS: - if (ccdc->output & CCDC_OUTPUT_MEMORY) { - if (ccdc->lsc.state != LSC_STATE_STOPPED) - __ccdc_lsc_enable(ccdc, 0); - __ccdc_enable(ccdc, 0); - } - break; + /* + * Depending on the CCDC pipeline state, CCDC stopping should be + * handled differently. In SINGLESHOT we emulate an internal CCDC + * stopping because the CCDC hw works only in continuous mode. + * When CONTINUOUS pipeline state is used and the CCDC writes it's + * data to memory the CCDC and LSC are stopped immediately but + * without change the CCDC stopping state machine. The CCDC + * stopping state machine should be used only when user request + * for stopping is received (SINGLESHOT is an exeption). + */ + switch (ccdc->state) { + case ISP_PIPELINE_STREAM_SINGLESHOT: + ccdc->stopping = CCDC_STOP_REQUEST; + break; - case ISP_PIPELINE_STREAM_STOPPED: - break; - } + case ISP_PIPELINE_STREAM_CONTINUOUS: + if (ccdc->output & CCDC_OUTPUT_MEMORY) { + if (ccdc->lsc.state != LSC_STATE_STOPPED) + __ccdc_lsc_enable(ccdc, 0); + __ccdc_enable(ccdc, 0); + } + break; - if (__ccdc_handle_stopping(ccdc, CCDC_EVENT_VD1)) - goto done; + case ISP_PIPELINE_STREAM_STOPPED: + break; + } - if (ccdc->lsc.request == NULL) - goto done; + if (__ccdc_handle_stopping(ccdc, CCDC_EVENT_VD1)) + goto done; - /* - * LSC need to be reconfigured. Stop it here and on next LSC_DONE IRQ - * do the appropriate changes in registers - */ - if (ccdc->lsc.state == LSC_STATE_RUNNING) { - __ccdc_lsc_enable(ccdc, 0); - ccdc->lsc.state = LSC_STATE_RECONFIG; - goto done; - } + if (ccdc->lsc.request == NULL) + goto done; - /* LSC has been in STOPPED state, enable it */ - if (ccdc->lsc.state == LSC_STATE_STOPPED) - ccdc_lsc_enable(ccdc); + /* + * LSC need to be reconfigured. Stop it here and on next + * LSC_DONE IRQ do the appropriate changes in registers + */ + if (ccdc->lsc.state == LSC_STATE_RUNNING) { + __ccdc_lsc_enable(ccdc, 0); + ccdc->lsc.state = LSC_STATE_RECONFIG; + goto done; + } + + /* LSC has been in STOPPED state, enable it */ + if (ccdc->lsc.state == LSC_STATE_STOPPED) + ccdc_lsc_enable(ccdc);done:
-spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags);
+spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); +
+ }
}/*
drivers/media/video/omap3isp/ispccdc.c +3
-0@@ -1638,6 +1714,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer) return -ENODEV; ccdc_set_outaddr(ccdc, buffer->isp_addr); + ccdc->current_buffer = buffer; /* We now have a buffer queued on the output, restart the pipeline* on the next CCDC interrupt if running in continuous mode (or when @@ -1764,6 +1841,8 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable) omap3isp_sbl_disable(isp, OMAP3_ISP_SBL_CCDC_WRITE); omap3isp_subclk_disable(isp, OMAP3_ISP_SUBCLK_CCDC); ccdc->underrun = 0; + ccdc->current_buffer = NULL; + ccdc->interlaced_cnt = 0; break; }(quoted diff) +0
-0
b/drivers/media/video/omap3isp/ispccdc.hindex 54811ce..dad021c 100644drivers/media/video/omap3isp/ispccdc.h +6
-0@@ -134,6 +134,9 @@ struct ispccdc_lsc {* @wait: Wait queue used to stop the module * @stopping: Stopping state * @ioctl_lock: Serializes ioctl calls and LSC requests freeing +* @current_buffer: Buffer for current frame +* @last_buffer: Buffer used for the last frame +* @interlaced_cnt: Sub-frame count for an interlaced video frame */ struct isp_ccdc_device { struct v4l2_subdev subdev;@@ -164,6 +167,9 @@ struct isp_ccdc_device { wait_queue_head_t wait; unsigned int stopping; struct mutex ioctl_lock; + struct isp_buffer *current_buffer; + struct isp_buffer *last_buffer; + unsigned int interlaced_cnt; };
Quoted 7 lines
drivers/media/video/omap3isp/ispccdc.h struct isp_ccdc_device { · line 175
Quoted 1 line
drivers/media/video/omap3isp/ispccdc.h +0
-0struct isp_device;--
Regards,Laurent Pinchart
Thanks a lot for your time to review this.
Best regards,
Signature · 3 lines
Javier Martínez Canillas (+34) 682 39 81 69 Barcelona, Spain
Re: [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
In reply to Laurent PinchartQuoted 3 lines · Laurent Pinchart
Hi Javier,
Thanks for the patch.
Laurent, apart from the specific comments on Javier code, did you have a look at Deepthy patches too?
I say this because asking Javier for fixes means (to me) that you are going to merge his patches (if testing will confirm it works of course). Am i wrong?
Btw i'm trying to get these patches on 3.1.0rc9 (from igep repository, that should be just like mainline 3.1.0rc9 with some bsp patches), i hope i will report good news.
Enrico
Re: [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
Quoted 4 lines · Enrico
Quoted 2 lines · Laurent Pinchart
Hi Javier,
Quoted 8 lines
Quoted 1 line
Thanks for the patch.
Laurent, apart from the specific comments on Javier code, did you have a look at Deepthy patches too?
I say this because asking Javier for fixes means (to me) that you are going to merge his patches (if testing will confirm it works of course). Am i wrong?
I don't think these patches are in merge-able state because I only compile tested.
Now based on Laurent's comments I just sent a v2 patch-set based in one of our earlier changes.
This was before we decide to move the logic to VD1 so the patch-set is less intrusive and will be easier to review.
Also, now I check for fldmode not bt656, Laurent's is right that bt.656 is interlaced but not every interlaced video is bt.656.
Quoted 7 lines
Btw i'm trying to get these patches on 3.1.0rc9 (from igep repository, that should be just like mainline 3.1.0rc9 with some bsp patches), i hope i will report good news.
Enrico
Great, thank you very much for your efforts Enrico.
Best regards,
Signature · 3 lines
Javier Martínez Canillas (+34) 682 39 81 69 Barcelona, Spain
Re: [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
In reply to EnricoQuoted 13 lines · Enrico
Quoted 3 lines · Laurent Pinchart
Hi Javier,
Thanks for the patch.
Laurent, apart from the specific comments on Javier code, did you have a look at Deepthy patches too?
I say this because asking Javier for fixes means (to me) that you are going to merge his patches (if testing will confirm it works of course). Am i wrong?
Quoted 6 lines
Btw i'm trying to get these patches on 3.1.0rc9 (from igep repository, that should be just like mainline 3.1.0rc9 with some bsp patches), i hope i will report good news.
Enrico
I just created a repository on my personal github account to keep the patches [1] and make it more easily accessible to people that want to try.
These already have the fix to the fact that ccdc_input_is_fldmode() was returning pdata->bt655 instead of pdata->fldmode.
I will try to test the patches tomorrow when I have access to the hardware but I can't promise because I have lots of other tasks to do.
[1]: https://github.com/martinezjavier/omap3isp/tree/master/omap3isp-yuv-patches
Best regards,
Signature · 3 lines
Javier Martínez Canillas (+34) 682 39 81 69 Barcelona, Spain
Hi Javier,
Thanks for the patches.
Quoted 13 lines · On Sunday 09 October 2011 04:37:31 Javier Martinez Canillas wrote:
This patch-set aims to add support to the ISP CCDC driver to process interlaced video data in ITU-R BT.656 format.
The patch-set contains the following patches:
[PATCH 1/2] omap3isp: video: Decouple buffer obtaining and set ISP entities format [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
The first patch decouples next frame buffer obtaining from the last frame buffer releasing. This change is needed by the second patch that moves most of the CCDC buffer management logic to the VD1 interrupt handler.
Quoted 8 lines
This patch-set is a proof-of-concept and was only compile tested since I don't have the hardware to test right now. It is a forward porting, on top of Laurent's omap3isp-omap3isp-yuv tree, of the changes we made to the ISP driver to get interlaced video working.
Also, the patch will brake other configurations since the resizer and previewer also make use of
omap3isp_video_buffer()function that now has a different semantic.
That's an issue you need to address :-)
Quoted 2 lines
I'm posting even when the patch-set is not in a merge-able state so you can review what we were doing and make comments.
You should split your patches differently. Even if we ignore the above issue, your first patch will break the CCDC. In order to ease bissection patches should be self-contained and not introduce regressions if possible.
Please see my comments to the second patch.
Quoted 5 lines
These are not all our changes since we also modified the ISP to forward the [G | S]_FMT and [G | S]_STD V4L2 ioctl commands to the TVP5151 and to only copy the active lines, but those changes are not relevant with the ghosting effect. With these changes we could get the 25 fps but with some sort of artifacts on the images.
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 23 lines · Laurent Pinchart
Hi Javier,
Thanks for the patches.
Quoted 18 lines · On Sunday 09 October 2011 04:37:31 Javier Martinez Canillas wrote:
This patch-set aims to add support to the ISP CCDC driver to process interlaced video data in ITU-R BT.656 format.
The patch-set contains the following patches:
[PATCH 1/2] omap3isp: video: Decouple buffer obtaining and set ISP entities format [PATCH 2/2] omap3isp: ccdc: Add support to ITU-R BT.656 video data format
The first patch decouples next frame buffer obtaining from the last frame buffer releasing. This change is needed by the second patch that moves most of the CCDC buffer management logic to the VD1 interrupt handler.
This patch-set is a proof-of-concept and was only compile tested since I don't have the hardware to test right now. It is a forward porting, on top of Laurent's omap3isp-omap3isp-yuv tree, of the changes we made to the ISP driver to get interlaced video working.
Quoted 6 lines
Quoted 3 lines
Also, the patch will brake other configurations since the resizer and previewer also make use of
omap3isp_video_buffer()function that now has a different semantic.That's an issue you need to address :-)
Hi Laurent,
Yes, I know :-)
The first version of the patch-set was only mean so you can review it but then I understood that your idea is to actually merge some code I send a few ours ago a v2 of the patch-set [1].
This v2 is a simpler code that doesn't move any of the logic to the VD1 interrupt handler so it won't brake others components (resizer, previewer, etc). So first we can focus to have a working version of the interlaced video data support in the driver and then try to fix the artifact effect issue.
It is based on an early version of our patch and also I've address all the issues you called out on the second patch. The fact that the code to address interlaced video is not bt656 but fldmode dependent.
Also I split the patches in atomic operations so it can be applied incrementally without breaking the driver.
Please let me know if you got the v2 patches or I can resend them if it is easier for you.
[1]: http://www.spinics.net/lists/linux-media/msg38973.html
Quoted 15 lines
Quoted 2 lines
I'm posting even when the patch-set is not in a merge-able state so you can review what we were doing and make comments.
You should split your patches differently. Even if we ignore the above issue, your first patch will break the CCDC. In order to ease bissection patches should be self-contained and not introduce regressions if possible.
Please see my comments to the second patch.
Quoted 5 lines
These are not all our changes since we also modified the ISP to forward the [G | S]_FMT and [G | S]_STD V4L2 ioctl commands to the TVP5151 and to only copy the active lines, but those changes are not relevant with the ghosting effect. With these changes we could get the 25 fps but with some sort of artifacts on the images.
Quoted 5 lines
--
Regards,Laurent Pinchart
Best regards,
Signature · 3 lines
Javier Martínez Canillas (+34) 682 39 81 69 Barcelona, Spain