Skip to content

Commit

Permalink
[media] omap3isp: ccdc: Add basic support for interlaced video
Browse files Browse the repository at this point in the history
When the CCDC input is interlaced enable the alternate field order on
the CCDC output video node. The field signal polarity is specified
through platform data.

Signed-off-by: Laurent Pinchart <[email protected]>
Tested-by: Enrico Butera <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
pinchartl authored and mchehab committed Aug 21, 2014
1 parent 0a7b1a0 commit 9a36d8e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
21 changes: 20 additions & 1 deletion drivers/media/platform/omap3isp/ispccdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,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->fld_pol)
syn_mode |= ISPCCDC_SYN_MODE_FLDPOL;

isp_reg_writel(isp, syn_mode, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SYN_MODE);

/* The CCDC_CFG.Y8POS bit is used in YCbCr8 input mode only. The
Expand Down Expand Up @@ -1140,6 +1143,7 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)

omap3isp_configure_bridge(isp, ccdc->input, pdata, shift, bridge);

/* Configure the sync interface. */
ccdc_config_sync_if(ccdc, pdata, depth_out);

syn_mode = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SYN_MODE);
Expand Down Expand Up @@ -1499,6 +1503,17 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc)
return 1;
}

/* When capturing fields in alternate order read the current field
* identifier and store it in the pipeline.
*/
if (ccdc->formats[CCDC_PAD_SOURCE_OF].field == V4L2_FIELD_ALTERNATE) {
u32 syn_mode = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCDC,
ISPCCDC_SYN_MODE);

pipe->field = syn_mode & ISPCCDC_SYN_MODE_FLDSTAT
? V4L2_FIELD_BOTTOM : V4L2_FIELD_TOP;
}

if (ccdc_sbl_wait_idle(ccdc, 1000)) {
dev_info(isp->dev, "CCDC won't become idle!\n");
isp->crashed |= 1U << ccdc->subdev.entity.id;
Expand Down Expand Up @@ -1830,6 +1845,11 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
/* Clamp the input size. */
fmt->width = clamp_t(u32, width, 32, 4096);
fmt->height = clamp_t(u32, height, 32, 4096);

/* Default to progressive field order. */
if (fmt->field == V4L2_FIELD_ANY)
fmt->field = V4L2_FIELD_NONE;

break;

case CCDC_PAD_SOURCE_OF:
Expand Down Expand Up @@ -1885,7 +1905,6 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
* stored on 2 bytes.
*/
fmt->colorspace = V4L2_COLORSPACE_SRGB;
fmt->field = V4L2_FIELD_NONE;
}

/*
Expand Down
6 changes: 6 additions & 0 deletions drivers/media/platform/omap3isp/ispvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
else
buf->vb.v4l2_buf.sequence = atomic_read(&pipe->frame_number);

if (pipe->field != V4L2_FIELD_NONE)
buf->vb.v4l2_buf.sequence /= 2;

buf->vb.v4l2_buf.field = pipe->field;

/* Report pipeline errors to userspace on the capture device side. */
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
state = VB2_BUF_STATE_ERROR;
Expand Down Expand Up @@ -1038,6 +1043,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
video->queue = &vfh->queue;
INIT_LIST_HEAD(&video->dmaqueue);
atomic_set(&pipe->frame_number, -1);
pipe->field = vfh->format.fmt.pix.field;

mutex_lock(&video->queue_lock);
ret = vb2_streamon(&vfh->queue, type);
Expand Down
2 changes: 2 additions & 0 deletions drivers/media/platform/omap3isp/ispvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ enum isp_pipeline_state {

/*
* struct isp_pipeline - An ISP hardware pipeline
* @field: The field being processed by the pipeline
* @error: A hardware error occurred during capture
* @entities: Bitmask of entities in the pipeline (indexed by entity ID)
*/
Expand All @@ -91,6 +92,7 @@ struct isp_pipeline {
u32 entities;
unsigned long l3_ick;
unsigned int max_rate;
enum v4l2_field field;
atomic_t frame_number;
bool do_propagation; /* of frame number */
bool error;
Expand Down
3 changes: 3 additions & 0 deletions include/media/omap3isp.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ enum {
* 0 - Active high, 1 - Active low
* @vs_pol: Vertical synchronization polarity
* 0 - Active high, 1 - Active low
* @fld_pol: Field signal polarity
* 0 - Positive, 1 - Negative
* @data_pol: Data polarity
* 0 - Normal, 1 - One's complement
*/
Expand All @@ -65,6 +67,7 @@ struct isp_parallel_platform_data {
unsigned int clk_pol:1;
unsigned int hs_pol:1;
unsigned int vs_pol:1;
unsigned int fld_pol:1;
unsigned int data_pol:1;
};

Expand Down

0 comments on commit 9a36d8e

Please sign in to comment.