diff options
author | Robby Cai <r63905@freescale.com> | 2009-10-13 13:33:16 +0800 |
---|---|---|
committer | Robby Cai <r63905@freescale.com> | 2009-10-14 16:50:33 +0800 |
commit | 688156f66bcf0e70d7b0bde329802d1b2a85c6c8 (patch) | |
tree | f752e05a7b7b84ddae095062798b3112c80bd0d9 /drivers | |
parent | 1c40f2f246a05445c1abf4a62fcb4b540a1230fa (diff) |
ENGR00117203 MX23 Fix the wrong operations on chromakey in PXP/V4L2 driver
Separate chromakey setting for s1 and s0.
Set chromakey for S1 via S_FMT
set chromakey for S0 via S_CTRL (with private CID)
Current V4l2 framework can not support this case with only S_FMT.
Signed-off-by: Robby Cai <r63905@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/pxp.c | 63 | ||||
-rw-r--r-- | drivers/media/video/pxp.h | 5 |
2 files changed, 52 insertions, 16 deletions
diff --git a/drivers/media/video/pxp.c b/drivers/media/video/pxp.c index bc15e9479d3b..26e45bbd0e74 100644 --- a/drivers/media/video/pxp.c +++ b/drivers/media/video/pxp.c @@ -127,6 +127,15 @@ struct v4l2_queryctrl pxp_controls[] = { .type = V4L2_CTRL_TYPE_INTEGER, }, { .id = V4L2_CID_PRIVATE_BASE + 2, + .name = "Set S0 Chromakey", + .minimum = -1, + .maximum = 0xFFFFFF, + .step = 1, + .default_value = -1, + .flags = 0, + .type = V4L2_CTRL_TYPE_INTEGER, + }, { + .id = V4L2_CID_PRIVATE_BASE + 3, .name = "YUV Colorspace", .minimum = 0, .maximum = 1, @@ -170,11 +179,30 @@ static void pxp_set_rgbbuf(struct pxps *pxp) BF_PXP_RGBSIZE_HEIGHT(pxp->fb.fmt.height)); } -static void pxp_set_colorkey(struct pxps *pxp) +static void pxp_set_s0colorkey(struct pxps *pxp) { /* Low and high are set equal. V4L does not allow a chromakey range */ - HW_PXP_S0COLORKEYLOW_WR(pxp->chromakey); - HW_PXP_S0COLORKEYHIGH_WR(pxp->chromakey); + if (pxp->s0_chromakey == -1) { + /* disable color key */ + HW_PXP_S0COLORKEYLOW_WR(0xFFFFFF); + HW_PXP_S0COLORKEYHIGH_WR(0x0); + } else { + HW_PXP_S0COLORKEYLOW_WR(pxp->s0_chromakey); + HW_PXP_S0COLORKEYHIGH_WR(pxp->s0_chromakey); + } +} + +static void pxp_set_s1colorkey(struct pxps *pxp) +{ + /* Low and high are set equal. V4L does not allow a chromakey range */ + if (pxp->s1_chromakey_state != 0 && pxp->s1_chromakey != -1) { + HW_PXP_OLCOLORKEYLOW_WR(pxp->s1_chromakey); + HW_PXP_OLCOLORKEYHIGH_WR(pxp->s1_chromakey); + } else { + /* disable color key */ + HW_PXP_OLCOLORKEYLOW_WR(0xFFFFFF); + HW_PXP_OLCOLORKEYHIGH_WR(0x0); + } } static void pxp_set_oln(struct pxps *pxp) @@ -199,7 +227,7 @@ static void pxp_set_olparam(struct pxps *pxp) if (pxp->global_alpha_state) olparam |= BF_PXP_OLnPARAM_ALPHA_CNTL( BV_PXP_OLnPARAM_ALPHA_CNTL__Override); - if (pxp->chromakey_state) + if (pxp->s1_chromakey_state) olparam |= BM_PXP_OLnPARAM_ENABLE_COLORKEY; if (pxp->overlay_state) olparam |= BM_PXP_OLnPARAM_ENABLE; @@ -313,6 +341,9 @@ static int pxp_set_cstate(struct pxps *pxp, struct v4l2_control *vc) pxp->s0_bgcolor = vc->value; pxp_set_s0bg(pxp); } else if (vc->id == V4L2_CID_PRIVATE_BASE + 2) { + pxp->s0_chromakey = vc->value; + pxp_set_s0colorkey(pxp); + } else if (vc->id == V4L2_CID_PRIVATE_BASE + 3) { pxp->yuv = vc->value; pxp_set_csc(pxp); } @@ -333,6 +364,8 @@ static int pxp_get_cstate(struct pxps *pxp, struct v4l2_control *vc) else if (vc->id == V4L2_CID_PRIVATE_BASE + 1) vc->value = pxp->s0_bgcolor; else if (vc->id == V4L2_CID_PRIVATE_BASE + 2) + vc->value = pxp->s0_chromakey; + else if (vc->id == V4L2_CID_PRIVATE_BASE + 3) vc->value = pxp->yuv; return 0; @@ -502,7 +535,7 @@ static int pxp_g_fmt_output_overlay(struct file *file, void *fh, struct v4l2_window *wf = &f->fmt.win; memset(wf, 0, sizeof(struct v4l2_window)); - wf->chromakey = pxp->chromakey; + wf->chromakey = pxp->s1_chromakey; wf->global_alpha = pxp->global_alpha; wf->field = V4L2_FIELD_NONE; wf->clips = NULL; @@ -522,14 +555,14 @@ static int pxp_try_fmt_output_overlay(struct file *file, void *fh, struct pxps *pxp = video_get_drvdata(video_devdata(file)); struct v4l2_window *wf = &f->fmt.win; struct v4l2_rect srect; - u32 chromakey = wf->chromakey; + u32 s1_chromakey = wf->chromakey; u8 global_alpha = wf->global_alpha; memcpy(&srect, &(wf->w), sizeof(struct v4l2_rect)); pxp_g_fmt_output_overlay(file, fh, f); - wf->chromakey = chromakey; + wf->chromakey = s1_chromakey; wf->global_alpha = global_alpha; /* Constrain parameters to the input buffer */ @@ -554,12 +587,12 @@ static int pxp_s_fmt_output_overlay(struct file *file, void *fh, pxp->srect.width = wf->w.width; pxp->srect.height = wf->w.height; pxp->global_alpha = wf->global_alpha; - pxp->chromakey = wf->chromakey; + pxp->s1_chromakey = wf->chromakey; pxp_set_s0param(pxp); pxp_set_s0crop(pxp); pxp_set_scaling(pxp); pxp_set_olparam(pxp); - pxp_set_colorkey(pxp); + pxp_set_s1colorkey(pxp); } return ret; @@ -769,7 +802,7 @@ static int pxp_g_fbuf(struct file *file, void *priv, fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; if (pxp->local_alpha_state) fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; - if (pxp->chromakey_state) + if (pxp->s1_chromakey_state) fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY; return 0; @@ -789,7 +822,7 @@ static int pxp_s_fbuf(struct file *file, void *priv, /* Global alpha overrides local alpha if both are requested */ if (pxp->global_alpha_state && pxp->local_alpha_state) pxp->local_alpha_state = 0; - pxp->chromakey_state = + pxp->s1_chromakey_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; pxp_set_olparam(pxp); @@ -949,8 +982,9 @@ static int pxp_hw_init(struct pxps *pxp) pxp->global_alpha_state = 0; pxp->global_alpha = 0; pxp->local_alpha_state = 0; - pxp->chromakey_state = 0; - pxp->chromakey = 0; + pxp->s1_chromakey_state = 0; + pxp->s1_chromakey = -1; + pxp->s0_chromakey = -1; /* Write default h/w config */ pxp_set_ctrl(pxp); @@ -958,7 +992,8 @@ static int pxp_hw_init(struct pxps *pxp) pxp_set_s0crop(pxp); pxp_set_oln(pxp); pxp_set_olparam(pxp); - pxp_set_colorkey(pxp); + pxp_set_s0colorkey(pxp); + pxp_set_s1colorkey(pxp); pxp_set_csc(pxp); return 0; diff --git a/drivers/media/video/pxp.h b/drivers/media/video/pxp.h index 0e2cd62969ca..4ac191fa7d65 100644 --- a/drivers/media/video/pxp.h +++ b/drivers/media/video/pxp.h @@ -41,6 +41,7 @@ struct pxps { u32 s0_width; u32 s0_height; u32 s0_bgcolor; + u32 s0_chromakey; struct v4l2_framebuffer fb; struct v4l2_rect drect; @@ -58,8 +59,8 @@ struct pxps { int global_alpha_state; u8 global_alpha; int local_alpha_state; - int chromakey_state; - u32 chromakey; + int s1_chromakey_state; + u32 s1_chromakey; }; struct pxp_data_format { |