Skip to content

Commit 9a36d8e

Browse files
pinchartlmchehab
authored andcommitted
[media] omap3isp: ccdc: Add basic support for interlaced video
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 <laurent.pinchart@ideasonboard.com> Tested-by: Enrico Butera <ebutera@users.sourceforge.net> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
1 parent 0a7b1a0 commit 9a36d8e

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎drivers/media/platform/omap3isp/ispccdc.c‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,9 @@ static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc,
10011001
if (pdata && pdata->vs_pol)
10021002
syn_mode |= ISPCCDC_SYN_MODE_VDPOL;
10031003

1004+
if (pdata && pdata->fld_pol)
1005+
syn_mode |= ISPCCDC_SYN_MODE_FLDPOL;
1006+
10041007
isp_reg_writel(isp, syn_mode, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SYN_MODE);
10051008

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

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

1146+
/* Configure the sync interface. */
11431147
ccdc_config_sync_if(ccdc, pdata, depth_out);
11441148

11451149
syn_mode = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SYN_MODE);
@@ -1499,6 +1503,17 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc)
14991503
return 1;
15001504
}
15011505

1506+
/* When capturing fields in alternate order read the current field
1507+
* identifier and store it in the pipeline.
1508+
*/
1509+
if (ccdc->formats[CCDC_PAD_SOURCE_OF].field == V4L2_FIELD_ALTERNATE) {
1510+
u32 syn_mode = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCDC,
1511+
ISPCCDC_SYN_MODE);
1512+
1513+
pipe->field = syn_mode & ISPCCDC_SYN_MODE_FLDSTAT
1514+
? V4L2_FIELD_BOTTOM : V4L2_FIELD_TOP;
1515+
}
1516+
15021517
if (ccdc_sbl_wait_idle(ccdc, 1000)) {
15031518
dev_info(isp->dev, "CCDC won't become idle!\n");
15041519
isp->crashed |= 1U << ccdc->subdev.entity.id;
@@ -1830,6 +1845,11 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
18301845
/* Clamp the input size. */
18311846
fmt->width = clamp_t(u32, width, 32, 4096);
18321847
fmt->height = clamp_t(u32, height, 32, 4096);
1848+
1849+
/* Default to progressive field order. */
1850+
if (fmt->field == V4L2_FIELD_ANY)
1851+
fmt->field = V4L2_FIELD_NONE;
1852+
18331853
break;
18341854

18351855
case CCDC_PAD_SOURCE_OF:
@@ -1885,7 +1905,6 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
18851905
* stored on 2 bytes.
18861906
*/
18871907
fmt->colorspace = V4L2_COLORSPACE_SRGB;
1888-
fmt->field = V4L2_FIELD_NONE;
18891908
}
18901909

18911910
/*

‎drivers/media/platform/omap3isp/ispvideo.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
482482
else
483483
buf->vb.v4l2_buf.sequence = atomic_read(&pipe->frame_number);
484484

485+
if (pipe->field != V4L2_FIELD_NONE)
486+
buf->vb.v4l2_buf.sequence /= 2;
487+
488+
buf->vb.v4l2_buf.field = pipe->field;
489+
485490
/* Report pipeline errors to userspace on the capture device side. */
486491
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
487492
state = VB2_BUF_STATE_ERROR;
@@ -1038,6 +1043,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
10381043
video->queue = &vfh->queue;
10391044
INIT_LIST_HEAD(&video->dmaqueue);
10401045
atomic_set(&pipe->frame_number, -1);
1046+
pipe->field = vfh->format.fmt.pix.field;
10411047

10421048
mutex_lock(&video->queue_lock);
10431049
ret = vb2_streamon(&vfh->queue, type);

‎drivers/media/platform/omap3isp/ispvideo.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ enum isp_pipeline_state {
7878

7979
/*
8080
* struct isp_pipeline - An ISP hardware pipeline
81+
* @field: The field being processed by the pipeline
8182
* @error: A hardware error occurred during capture
8283
* @entities: Bitmask of entities in the pipeline (indexed by entity ID)
8384
*/
@@ -91,6 +92,7 @@ struct isp_pipeline {
9192
u32 entities;
9293
unsigned long l3_ick;
9394
unsigned int max_rate;
95+
enum v4l2_field field;
9496
atomic_t frame_number;
9597
bool do_propagation; /* of frame number */
9698
bool error;

‎include/media/omap3isp.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ enum {
5757
* 0 - Active high, 1 - Active low
5858
* @vs_pol: Vertical synchronization polarity
5959
* 0 - Active high, 1 - Active low
60+
* @fld_pol: Field signal polarity
61+
* 0 - Positive, 1 - Negative
6062
* @data_pol: Data polarity
6163
* 0 - Normal, 1 - One's complement
6264
*/
@@ -65,6 +67,7 @@ struct isp_parallel_platform_data {
6567
unsigned int clk_pol:1;
6668
unsigned int hs_pol:1;
6769
unsigned int vs_pol:1;
70+
unsigned int fld_pol:1;
6871
unsigned int data_pol:1;
6972
};
7073

0 commit comments

Comments
 (0)