diff options
author | Robby Cai <R63905@freescale.com> | 2010-02-26 11:00:18 +0800 |
---|---|---|
committer | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2010-05-25 11:17:16 +0200 |
commit | f2b7b7c5361b9ed4c5adb0f6bcb4738f50733424 (patch) | |
tree | e5127abe6932463c827e3134a71a78eaa250a615 /drivers | |
parent | 65f3cd8afd4803654736df00601d7d951d62cfc2 (diff) |
ENGR00117731 MX28: PxP and V4L2 driver Porting
Porting PxP(combined with V4L2) driver onto MX28
Signed-off-by: Robby Cai <R63905@freescale.com>
Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/Kconfig | 4 | ||||
-rw-r--r-- | drivers/media/video/pxp.c | 543 | ||||
-rw-r--r-- | drivers/media/video/pxp.h | 27 |
3 files changed, 289 insertions, 285 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 7210c4f3c355..9183ebd20851 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -569,8 +569,8 @@ config VIDEO_MXC_OUTPUT source "drivers/media/video/mxc/output/Kconfig" config VIDEO_PXP - tristate "STMP3xxx PxP" - depends on VIDEO_DEV && VIDEO_V4L2 && ARCH_STMP3XXX + tristate "MXS PxP" + depends on VIDEO_DEV && VIDEO_V4L2 && (ARCH_STMP3XXX || ARCH_MXS) select VIDEOBUF_DMA_CONTIG ---help--- This is a video4linux driver for the Freescale PxP diff --git a/drivers/media/video/pxp.c b/drivers/media/video/pxp.c index 0aaa93af6094..e49636212b59 100644 --- a/drivers/media/video/pxp.c +++ b/drivers/media/video/pxp.c @@ -1,22 +1,26 @@ /* - * Freescale STMP378X PxP driver + * Freescale MXS PxP driver * * Author: Matt Porter <mporter@embeddedalley.com> * * Copyright 2008-2010 Freescale Semiconductor, Inc. * Copyright 2008-2009 Embedded Alley Solutions, Inc All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <linux/dma-mapping.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/interrupt.h> @@ -33,13 +37,15 @@ #include <media/v4l2-dev.h> #include <media/v4l2-ioctl.h> -#include <mach/platform.h> +#include <mach/hardware.h> #include <mach/regs-pxp.h> #include <mach/lcdif.h> #include "pxp.h" -#define PXP_DRIVER_NAME "stmp3xxx-pxp" +#define PXP_BASE_ADDR IO_ADDRESS(PXP_PHYS_ADDR) + +#define PXP_DRIVER_NAME "mxs-pxp" #define PXP_DRIVER_MAJOR 1 #define PXP_DRIVER_MINOR 0 @@ -48,8 +54,8 @@ #define V4L2_OUTPUT_TYPE_INTERNAL 4 -#define PXP_WAITCON ((__raw_readl(HW_PXP_NEXT_ADDR) & BM_PXP_NEXT_ENABLED) \ - != BM_PXP_NEXT_ENABLED) +#define PXP_WAITCON ((__raw_readl(PXP_BASE_ADDR + HW_PXP_NEXT) & \ + BM_PXP_NEXT_ENABLED) != BM_PXP_NEXT_ENABLED) #define REG_OFFSET 0x10 #define REGS1_NUMS 16 @@ -61,103 +67,111 @@ static u32 regs3[REGS3_NUMS]; static struct pxp_data_format pxp_s0_formats[] = { { - .name = "24-bit RGB", - .bpp = 4, - .fourcc = V4L2_PIX_FMT_RGB24, - .colorspace = V4L2_COLORSPACE_SRGB, - .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__RGB888, - }, { - .name = "16-bit RGB 5:6:5", - .bpp = 2, - .fourcc = V4L2_PIX_FMT_RGB565, - .colorspace = V4L2_COLORSPACE_SRGB, - .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__RGB565, - }, { - .name = "16-bit RGB 5:5:5", - .bpp = 2, - .fourcc = V4L2_PIX_FMT_RGB555, - .colorspace = V4L2_COLORSPACE_SRGB, - .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__RGB555, - }, { - .name = "YUV 4:2:0 Planar", - .bpp = 2, - .fourcc = V4L2_PIX_FMT_YUV420, - .colorspace = V4L2_COLORSPACE_JPEG, - .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__YUV420, - }, { - .name = "YUV 4:2:2 Planar", - .bpp = 2, - .fourcc = V4L2_PIX_FMT_YUV422P, - .colorspace = V4L2_COLORSPACE_JPEG, - .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__YUV422, - }, + .name = "24-bit RGB", + .bpp = 4, + .fourcc = V4L2_PIX_FMT_RGB24, + .colorspace = V4L2_COLORSPACE_SRGB, + .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__RGB888, + }, + { + .name = "16-bit RGB 5:6:5", + .bpp = 2, + .fourcc = V4L2_PIX_FMT_RGB565, + .colorspace = V4L2_COLORSPACE_SRGB, + .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__RGB565, + }, + { + .name = "16-bit RGB 5:5:5", + .bpp = 2, + .fourcc = V4L2_PIX_FMT_RGB555, + .colorspace = V4L2_COLORSPACE_SRGB, + .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__RGB555, + }, + { + .name = "YUV 4:2:0 Planar", + .bpp = 2, + .fourcc = V4L2_PIX_FMT_YUV420, + .colorspace = V4L2_COLORSPACE_JPEG, + .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__YUV420, + }, + { + .name = "YUV 4:2:2 Planar", + .bpp = 2, + .fourcc = V4L2_PIX_FMT_YUV422P, + .colorspace = V4L2_COLORSPACE_JPEG, + .ctrl_s0_fmt = BV_PXP_CTRL_S0_FORMAT__YUV422, + }, }; struct v4l2_queryctrl pxp_controls[] = { { - .id = V4L2_CID_HFLIP, - .type = V4L2_CTRL_TYPE_BOOLEAN, - .name = "Horizontal Flip", - .minimum = 0, - .maximum = 1, - .step = 1, - .default_value = 0, - .flags = 0, - }, { - .id = V4L2_CID_VFLIP, - .type = V4L2_CTRL_TYPE_BOOLEAN, - .name = "Vertical Flip", - .minimum = 0, - .maximum = 1, - .step = 1, - .default_value = 0, - .flags = 0, - }, { - .id = V4L2_CID_PRIVATE_BASE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Rotation", - .minimum = 0, - .maximum = 270, - .step = 90, - .default_value = 0, - .flags = 0, - }, { - .id = V4L2_CID_PRIVATE_BASE + 1, - .name = "Background Color", - .minimum = 0, - .maximum = 0xFFFFFF, - .step = 1, - .default_value = 0, - .flags = 0, - .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, - .step = 1, - .default_value = 0, - .flags = 0, - .type = V4L2_CTRL_TYPE_BOOLEAN, - }, + .id = V4L2_CID_HFLIP, + .type = V4L2_CTRL_TYPE_BOOLEAN, + .name = "Horizontal Flip", + .minimum = 0, + .maximum = 1, + .step = 1, + .default_value = 0, + .flags = 0, + }, + { + .id = V4L2_CID_VFLIP, + .type = V4L2_CTRL_TYPE_BOOLEAN, + .name = "Vertical Flip", + .minimum = 0, + .maximum = 1, + .step = 1, + .default_value = 0, + .flags = 0, + }, + { + .id = V4L2_CID_PRIVATE_BASE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "Rotation", + .minimum = 0, + .maximum = 270, + .step = 90, + .default_value = 0, + .flags = 0, + }, + { + .id = V4L2_CID_PRIVATE_BASE + 1, + .name = "Background Color", + .minimum = 0, + .maximum = 0xFFFFFF, + .step = 1, + .default_value = 0, + .flags = 0, + .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, + .step = 1, + .default_value = 0, + .flags = 0, + .type = V4L2_CTRL_TYPE_BOOLEAN, + }, }; static void pxp_set_ctrl(struct pxps *pxp) { u32 ctrl; - ctrl = BF(pxp->s0_fmt->ctrl_s0_fmt, PXP_CTRL_S0_FORMAT); - ctrl |= - BF(BV_PXP_CTRL_OUTPUT_RGB_FORMAT__RGB888, PXP_CTRL_OUTPUT_RGB_FORMAT); + ctrl = BF_PXP_CTRL_S0_FORMAT(pxp->s0_fmt->ctrl_s0_fmt); + ctrl |= BF_PXP_CTRL_OUTBUF_FORMAT(BV_PXP_CTRL_OUTBUF_FORMAT__RGB888); ctrl |= BM_PXP_CTRL_CROP; if (pxp->scaling) @@ -167,13 +181,13 @@ static void pxp_set_ctrl(struct pxps *pxp) if (pxp->hflip) ctrl |= BM_PXP_CTRL_HFLIP; if (pxp->rotate) - ctrl |= BF(pxp->rotate/90, PXP_CTRL_ROTATE); + ctrl |= BF_PXP_CTRL_ROTATE(pxp->rotate / 90); ctrl |= BM_PXP_CTRL_IRQ_ENABLE; if (pxp->active) ctrl |= BM_PXP_CTRL_ENABLE; - __raw_writel(ctrl, HW_PXP_CTRL_ADDR); + __raw_writel(ctrl, PXP_BASE_ADDR + HW_PXP_CTRL); pxp->regs_virt->ctrl = ctrl; } @@ -181,8 +195,8 @@ static void pxp_set_rgbbuf(struct pxps *pxp) { pxp->regs_virt->rgbbuf = pxp->outb_phys; /* Always equal to the FB size */ - pxp->regs_virt->rgbsize = BF(pxp->fb.fmt.width, PXP_RGBSIZE_WIDTH) | - BF(pxp->fb.fmt.height, PXP_RGBSIZE_HEIGHT); + pxp->regs_virt->rgbsize = BF_PXP_OUTSIZE_WIDTH(pxp->fb.fmt.width) | + BF_PXP_OUTSIZE_HEIGHT(pxp->fb.fmt.height); } static void pxp_set_s0colorkey(struct pxps *pxp) @@ -213,10 +227,10 @@ static void pxp_set_s1colorkey(struct pxps *pxp) static void pxp_set_oln(struct pxps *pxp) { - pxp->regs_virt->ol0.ol = (u32)pxp->fb.base; + pxp->regs_virt->ol0.ol = (u32) pxp->fb.base; pxp->regs_virt->ol0.olsize = - BF(pxp->fb.fmt.width >> 3, PXP_OLnSIZE_WIDTH) | - BF(pxp->fb.fmt.height >> 3, PXP_OLnSIZE_HEIGHT); + BF_PXP_OLnSIZE_WIDTH(pxp->fb.fmt.width >> 3) | + BF_PXP_OLnSIZE_HEIGHT(pxp->fb.fmt.height >> 3); } static void pxp_set_olparam(struct pxps *pxp) @@ -224,16 +238,17 @@ static void pxp_set_olparam(struct pxps *pxp) u32 olparam; struct v4l2_pix_format *fmt = &pxp->fb.fmt; - olparam = BF(pxp->global_alpha, PXP_OLnPARAM_ALPHA); + olparam = BF_PXP_OLnPARAM_ALPHA(pxp->global_alpha); if (fmt->pixelformat == V4L2_PIX_FMT_RGB24) olparam |= - BF(BV_PXP_OLnPARAM_FORMAT__RGB888, PXP_OLnPARAM_FORMAT); + BF_PXP_OLnPARAM_FORMAT(BV_PXP_OLnPARAM_FORMAT__RGB888); else olparam |= - BF(BV_PXP_OLnPARAM_FORMAT__RGB565, PXP_OLnPARAM_FORMAT); + BF_PXP_OLnPARAM_FORMAT(BV_PXP_OLnPARAM_FORMAT__RGB565); if (pxp->global_alpha_state) - olparam |= BF(BV_PXP_OLnPARAM_ALPHA_CNTL__Override, - PXP_OLnPARAM_ALPHA_CNTL); + olparam |= + BF_PXP_OLnPARAM_ALPHA_CNTL + (BV_PXP_OLnPARAM_ALPHA_CNTL__Override); if (pxp->s1_chromakey_state) olparam |= BM_PXP_OLnPARAM_ENABLE_COLORKEY; if (pxp->overlay_state) @@ -246,10 +261,10 @@ static void pxp_set_s0param(struct pxps *pxp) { u32 s0param; - s0param = BF(pxp->drect.left >> 3, PXP_S0PARAM_XBASE); - s0param |= BF(pxp->drect.top >> 3, PXP_S0PARAM_YBASE); - s0param |= BF(pxp->s0_width >> 3, PXP_S0PARAM_WIDTH); - s0param |= BF(pxp->s0_height >> 3, PXP_S0PARAM_HEIGHT); + s0param = BF_PXP_S0PARAM_XBASE(pxp->drect.left >> 3); + s0param |= BF_PXP_S0PARAM_YBASE(pxp->drect.top >> 3); + s0param |= BF_PXP_S0PARAM_WIDTH(pxp->s0_width >> 3); + s0param |= BF_PXP_S0PARAM_HEIGHT(pxp->s0_height >> 3); pxp->regs_virt->s0param = s0param; } @@ -257,10 +272,10 @@ static void pxp_set_s0crop(struct pxps *pxp) { u32 s0crop; - s0crop = BF(pxp->srect.left >> 3, PXP_S0CROP_XBASE); - s0crop |= BF(pxp->srect.top >> 3, PXP_S0CROP_YBASE); - s0crop |= BF(pxp->drect.width >> 3, PXP_S0CROP_WIDTH); - s0crop |= BF(pxp->drect.height >> 3, PXP_S0CROP_HEIGHT); + s0crop = BF_PXP_S0CROP_XBASE(pxp->srect.left >> 3); + s0crop |= BF_PXP_S0CROP_YBASE(pxp->srect.top >> 3); + s0crop |= BF_PXP_S0CROP_WIDTH(pxp->drect.width >> 3); + s0crop |= BF_PXP_S0CROP_HEIGHT(pxp->drect.height >> 3); pxp->regs_virt->s0crop = s0crop; } @@ -270,14 +285,14 @@ static int pxp_set_scaling(struct pxps *pxp) u32 xscale, yscale, s0scale; if ((pxp->s0_fmt->fourcc != V4L2_PIX_FMT_YUV420) && - (pxp->s0_fmt->fourcc != V4L2_PIX_FMT_YUV422P)) { + (pxp->s0_fmt->fourcc != V4L2_PIX_FMT_YUV422P)) { pxp->scaling = 0; ret = -EINVAL; goto out; } if ((pxp->srect.width == pxp->drect.width) && - (pxp->srect.height == pxp->drect.height)) { + (pxp->srect.height == pxp->drect.height)) { pxp->scaling = 0; goto out; } @@ -285,8 +300,7 @@ static int pxp_set_scaling(struct pxps *pxp) pxp->scaling = 1; xscale = pxp->srect.width * 0x1000 / pxp->drect.width; yscale = pxp->srect.height * 0x1000 / pxp->drect.height; - s0scale = BF(yscale, PXP_S0SCALE_YSCALE) | - BF(xscale, PXP_S0SCALE_XSCALE); + s0scale = BF_PXP_S0SCALE_YSCALE(yscale) | BF_PXP_S0SCALE_XSCALE(xscale); pxp->regs_virt->s0scale = s0scale; out: @@ -302,7 +316,7 @@ static int pxp_set_fbinfo(struct pxps *pxp) struct v4l2_framebuffer *fb = &pxp->fb; int err; - err = stmp3xxxfb_get_info(&var, &fix); + err = mxsfb_get_info(&var, &fix); fb->fmt.width = var.xres; fb->fmt.height = var.yres; @@ -323,14 +337,14 @@ static void pxp_set_csc(struct pxps *pxp) { if (pxp->yuv) { /* YUV colorspace */ - __raw_writel(0x04030000, HW_PXP_CSCCOEFF0_ADDR); - __raw_writel(0x01230208, HW_PXP_CSCCOEFF1_ADDR); - __raw_writel(0x076b079c, HW_PXP_CSCCOEFF2_ADDR); + __raw_writel(0x04030000, PXP_BASE_ADDR + HW_PXP_CSCCOEFF0); + __raw_writel(0x01230208, PXP_BASE_ADDR + HW_PXP_CSCCOEFF1); + __raw_writel(0x076b079b, PXP_BASE_ADDR + HW_PXP_CSCCOEFF2); } else { /* YCrCb colorspace */ - __raw_writel(0x84ab01f0, HW_PXP_CSCCOEFF0_ADDR); - __raw_writel(0x01230204, HW_PXP_CSCCOEFF1_ADDR); - __raw_writel(0x0730079c, HW_PXP_CSCCOEFF2_ADDR); + __raw_writel(0x84ab01f0, PXP_BASE_ADDR + HW_PXP_CSCCOEFF0); + __raw_writel(0x01230204, PXP_BASE_ADDR + HW_PXP_CSCCOEFF1); + __raw_writel(0x0730079c, PXP_BASE_ADDR + HW_PXP_CSCCOEFF2); } } @@ -379,8 +393,7 @@ static int pxp_get_cstate(struct pxps *pxp, struct v4l2_control *vc) return 0; } -static int pxp_enumoutput(struct file *file, void *fh, - struct v4l2_output *o) +static int pxp_enumoutput(struct file *file, void *fh, struct v4l2_output *o) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); @@ -402,8 +415,7 @@ static int pxp_enumoutput(struct file *file, void *fh, return 0; } -static int pxp_g_output(struct file *file, void *fh, - unsigned int *i) +static int pxp_g_output(struct file *file, void *fh, unsigned int *i) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); @@ -412,8 +424,7 @@ static int pxp_g_output(struct file *file, void *fh, return 0; } -static int pxp_s_output(struct file *file, void *fh, - unsigned int i) +static int pxp_s_output(struct file *file, void *fh, unsigned int i) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); struct v4l2_pix_format *fmt = &pxp->fb.fmt; @@ -434,7 +445,7 @@ static int pxp_s_output(struct file *file, void *fh, pxp->outb = kmalloc(fmt->width * fmt->height * bpp, GFP_KERNEL); pxp->outb_phys = virt_to_phys(pxp->outb); dma_map_single(NULL, pxp->outb, - fmt->width * fmt->height * bpp, DMA_TO_DEVICE); + fmt->width * fmt->height * bpp, DMA_TO_DEVICE); out: pxp_set_rgbbuf(pxp); @@ -443,7 +454,7 @@ out: } static int pxp_enum_fmt_video_output(struct file *file, void *fh, - struct v4l2_fmtdesc *fmt) + struct v4l2_fmtdesc *fmt) { enum v4l2_buf_type type = fmt->type; int index = fmt->index; @@ -461,7 +472,7 @@ static int pxp_enum_fmt_video_output(struct file *file, void *fh, } static int pxp_g_fmt_video_output(struct file *file, void *fh, - struct v4l2_format *f) + struct v4l2_format *f) { struct v4l2_pix_format *pf = &f->fmt.pix; struct pxps *pxp = video_get_drvdata(video_devdata(file)); @@ -497,7 +508,7 @@ static struct pxp_data_format *pxp_get_format(struct v4l2_format *f) } static int pxp_try_fmt_video_output(struct file *file, void *fh, - struct v4l2_format *f) + struct v4l2_format *f) { int w = f->fmt.pix.width; int h = f->fmt.pix.height; @@ -519,7 +530,7 @@ static int pxp_try_fmt_video_output(struct file *file, void *fh, } static int pxp_s_fmt_video_output(struct file *file, void *fh, - struct v4l2_format *f) + struct v4l2_format *f) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); struct v4l2_pix_format *pf = &f->fmt.pix; @@ -537,7 +548,7 @@ static int pxp_s_fmt_video_output(struct file *file, void *fh, } static int pxp_g_fmt_output_overlay(struct file *file, void *fh, - struct v4l2_format *f) + struct v4l2_format *f) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); struct v4l2_window *wf = &f->fmt.win; @@ -558,7 +569,7 @@ static int pxp_g_fmt_output_overlay(struct file *file, void *fh, } static int pxp_try_fmt_output_overlay(struct file *file, void *fh, - struct v4l2_format *f) + struct v4l2_format *f) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); struct v4l2_window *wf = &f->fmt.win; @@ -576,14 +587,14 @@ static int pxp_try_fmt_output_overlay(struct file *file, void *fh, /* Constrain parameters to the input buffer */ wf->w.left = srect.left; wf->w.top = srect.top; - wf->w.width = min(srect.width, ((__s32)pxp->s0_width - wf->w.left)); - wf->w.height = min(srect.height, ((__s32)pxp->s0_height - wf->w.top)); + wf->w.width = min(srect.width, ((__s32) pxp->s0_width - wf->w.left)); + wf->w.height = min(srect.height, ((__s32) pxp->s0_height - wf->w.top)); return 0; } static int pxp_s_fmt_output_overlay(struct file *file, void *fh, - struct v4l2_format *f) + struct v4l2_format *f) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); struct v4l2_window *wf = &f->fmt.win; @@ -607,39 +618,35 @@ static int pxp_s_fmt_output_overlay(struct file *file, void *fh, } static int pxp_reqbufs(struct file *file, void *priv, - struct v4l2_requestbuffers *r) + struct v4l2_requestbuffers *r) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); return videobuf_reqbufs(&pxp->s0_vbq, r); } -static int pxp_querybuf(struct file *file, void *priv, - struct v4l2_buffer *b) +static int pxp_querybuf(struct file *file, void *priv, struct v4l2_buffer *b) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); return videobuf_querybuf(&pxp->s0_vbq, b); } -static int pxp_qbuf(struct file *file, void *priv, - struct v4l2_buffer *b) +static int pxp_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); return videobuf_qbuf(&pxp->s0_vbq, b); } -static int pxp_dqbuf(struct file *file, void *priv, - struct v4l2_buffer *b) +static int pxp_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); return videobuf_dqbuf(&pxp->s0_vbq, b, file->f_flags & O_NONBLOCK); } -static int pxp_streamon(struct file *file, void *priv, - enum v4l2_buf_type t) +static int pxp_streamon(struct file *file, void *priv, enum v4l2_buf_type t) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); int ret = 0; @@ -650,13 +657,12 @@ static int pxp_streamon(struct file *file, void *priv, ret = videobuf_streamon(&pxp->s0_vbq); if (!ret && (pxp->output == 0)) - stmp3xxxfb_cfg_pxp(1, pxp->outb_phys); + mxsfb_cfg_pxp(1, pxp->outb_phys); return ret; } -static int pxp_streamoff(struct file *file, void *priv, - enum v4l2_buf_type t) +static int pxp_streamoff(struct file *file, void *priv, enum v4l2_buf_type t) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); int ret = 0; @@ -667,13 +673,13 @@ static int pxp_streamoff(struct file *file, void *priv, ret = videobuf_streamoff(&pxp->s0_vbq); if (!ret) - stmp3xxxfb_cfg_pxp(0, 0); + mxsfb_cfg_pxp(0, 0); return ret; } static int pxp_buf_setup(struct videobuf_queue *q, - unsigned int *count, unsigned *size) + unsigned int *count, unsigned *size) { struct pxps *pxp = q->priv_data; @@ -696,8 +702,7 @@ static void pxp_buf_free(struct videobuf_queue *q, struct videobuf_buffer *vb) } static int pxp_buf_prepare(struct videobuf_queue *q, - struct videobuf_buffer *vb, - enum v4l2_field field) + struct videobuf_buffer *vb, enum v4l2_field field) { struct pxps *pxp = q->priv_data; int ret = 0; @@ -739,10 +744,11 @@ static void pxp_buf_next(struct pxps *pxp) pxp->regs_virt->s0vbuf = V; } pxp->regs_virt->ctrl = - __raw_readl(HW_PXP_CTRL_ADDR) | BM_PXP_CTRL_ENABLE; + __raw_readl(PXP_BASE_ADDR + + HW_PXP_CTRL) | BM_PXP_CTRL_ENABLE; } - __raw_writel(pxp->regs_phys, HW_PXP_NEXT_ADDR); + __raw_writel(pxp->regs_phys, PXP_BASE_ADDR + HW_PXP_NEXT); } static void pxp_next_handle(struct work_struct *w) @@ -760,19 +766,18 @@ static void pxp_next_handle(struct work_struct *w) spin_unlock_irqrestore(&pxp->lock, flags); if (!wait_event_interruptible_timeout(pxp->done, PXP_WAITCON, - 5 * HZ) || signal_pending(current)) { + 5 * HZ) + || signal_pending(current)) { spin_lock_irqsave(&pxp->lock, flags); list_for_each_entry_safe(buf, next, &pxp->nextq, queue) - list_del(&buf->queue); + list_del(&buf->queue); spin_unlock_irqrestore(&pxp->lock, flags); pxp->next_queue_ended = 1; return; } spin_lock_irqsave(&pxp->lock, flags); - buf = list_entry(pxp->nextq.next, - struct pxp_buffer, - queue); + buf = list_entry(pxp->nextq.next, struct pxp_buffer, queue); list_del_init(&buf->queue); pxp->active = &buf->vb; pxp->active->state = VIDEOBUF_QUEUED; @@ -782,8 +787,7 @@ static void pxp_next_handle(struct work_struct *w) spin_unlock_irqrestore(&pxp->lock, flags); } -static void pxp_buf_queue(struct videobuf_queue *q, - struct videobuf_buffer *vb) +static void pxp_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) { struct pxps *pxp = q->priv_data; struct pxp_buffer *buf; @@ -809,16 +813,16 @@ static void pxp_buf_queue(struct videobuf_queue *q, } static void pxp_buf_release(struct videobuf_queue *q, - struct videobuf_buffer *vb) + struct videobuf_buffer *vb) { pxp_buf_free(q, vb); } static struct videobuf_queue_ops pxp_vbq_ops = { - .buf_setup = pxp_buf_setup, - .buf_prepare = pxp_buf_prepare, - .buf_queue = pxp_buf_queue, - .buf_release = pxp_buf_release, + .buf_setup = pxp_buf_setup, + .buf_prepare = pxp_buf_prepare, + .buf_queue = pxp_buf_queue, + .buf_release = pxp_buf_release, }; static int pxp_querycap(struct file *file, void *fh, @@ -829,28 +833,27 @@ static int pxp_querycap(struct file *file, void *fh, memset(cap, 0, sizeof(*cap)); strcpy(cap->driver, "pxp"); strcpy(cap->card, "pxp"); - strlcpy(cap->bus_info, dev_name(&pxp->pdev->dev), sizeof(cap->bus_info)); + strlcpy(cap->bus_info, dev_name(&pxp->pdev->dev), + sizeof(cap->bus_info)); cap->version = (PXP_DRIVER_MAJOR << 8) + PXP_DRIVER_MINOR; cap->capabilities = V4L2_CAP_VIDEO_OUTPUT | - V4L2_CAP_VIDEO_OUTPUT_OVERLAY | - V4L2_CAP_STREAMING; + V4L2_CAP_VIDEO_OUTPUT_OVERLAY | V4L2_CAP_STREAMING; return 0; } static int pxp_g_fbuf(struct file *file, void *priv, - struct v4l2_framebuffer *fb) + struct v4l2_framebuffer *fb) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); memset(fb, 0, sizeof(*fb)); fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | - V4L2_FBUF_CAP_CHROMAKEY | - V4L2_FBUF_CAP_LOCAL_ALPHA | - V4L2_FBUF_CAP_GLOBAL_ALPHA; + V4L2_FBUF_CAP_CHROMAKEY | + V4L2_FBUF_CAP_LOCAL_ALPHA | V4L2_FBUF_CAP_GLOBAL_ALPHA; if (pxp->global_alpha_state) fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; @@ -863,21 +866,18 @@ static int pxp_g_fbuf(struct file *file, void *priv, } static int pxp_s_fbuf(struct file *file, void *priv, - struct v4l2_framebuffer *fb) + struct v4l2_framebuffer *fb) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); - pxp->overlay_state = - (fb->flags & V4L2_FBUF_FLAG_OVERLAY) != 0; + pxp->overlay_state = (fb->flags & V4L2_FBUF_FLAG_OVERLAY) != 0; pxp->global_alpha_state = - (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; - pxp->local_alpha_state = - (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0; + (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; + pxp->local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0; /* Global alpha overrides local alpha if both are requested */ if (pxp->global_alpha_state && pxp->local_alpha_state) pxp->local_alpha_state = 0; - pxp->s1_chromakey_state = - (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; + pxp->s1_chromakey_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; pxp_set_olparam(pxp); pxp_set_s0crop(pxp); @@ -886,8 +886,7 @@ static int pxp_s_fbuf(struct file *file, void *priv, return 0; } -static int pxp_g_crop(struct file *file, void *fh, - struct v4l2_crop *c) +static int pxp_g_crop(struct file *file, void *fh, struct v4l2_crop *c) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); @@ -902,8 +901,7 @@ static int pxp_g_crop(struct file *file, void *fh, return 0; } -static int pxp_s_crop(struct file *file, void *fh, - struct v4l2_crop *c) +static int pxp_s_crop(struct file *file, void *fh, struct v4l2_crop *c) { struct pxps *pxp = video_get_drvdata(video_devdata(file)); int l = c->c.left; @@ -958,8 +956,7 @@ static int pxp_queryctrl(struct file *file, void *priv, return -EINVAL; } -static int pxp_g_ctrl(struct file *file, void *priv, - struct v4l2_control *vc) +static int pxp_g_ctrl(struct file *file, void *priv, struct v4l2_control *vc) { int i; @@ -972,8 +969,7 @@ static int pxp_g_ctrl(struct file *file, void *priv, return -EINVAL; } -static int pxp_s_ctrl(struct file *file, void *priv, - struct v4l2_control *vc) +static int pxp_s_ctrl(struct file *file, void *priv, struct v4l2_control *vc) { int i; struct pxps *pxp = video_get_drvdata(video_devdata(file)); @@ -1004,12 +1000,12 @@ static int pxp_hw_init(struct pxps *pxp) struct fb_fix_screeninfo fix; int err; - err = stmp3xxxfb_get_info(&var, &fix); + err = mxsfb_get_info(&var, &fix); if (err) return err; /* Pull PxP out of reset */ - __raw_writel(0, HW_PXP_CTRL_ADDR); + __raw_writel(0, PXP_BASE_ADDR + HW_PXP_CTRL); /* Config defaults */ pxp->active = NULL; @@ -1075,13 +1071,12 @@ out: pxp->workqueue = create_singlethread_workqueue("pxp"); videobuf_queue_dma_contig_init(&pxp->s0_vbq, - &pxp_vbq_ops, - &pxp->pdev->dev, - &pxp->lock, - V4L2_BUF_TYPE_VIDEO_OUTPUT, - V4L2_FIELD_NONE, - sizeof(struct pxp_buffer), - pxp); + &pxp_vbq_ops, + &pxp->pdev->dev, + &pxp->lock, + V4L2_BUF_TYPE_VIDEO_OUTPUT, + V4L2_FIELD_NONE, + sizeof(struct pxp_buffer), pxp); return 0; } @@ -1115,57 +1110,55 @@ static int pxp_mmap(struct file *file, struct vm_area_struct *vma) } static const struct v4l2_file_operations pxp_fops = { - .owner = THIS_MODULE, - .open = pxp_open, - .release = pxp_close, - .ioctl = video_ioctl2, - .mmap = pxp_mmap, + .owner = THIS_MODULE, + .open = pxp_open, + .release = pxp_close, + .ioctl = video_ioctl2, + .mmap = pxp_mmap, }; static const struct v4l2_ioctl_ops pxp_ioctl_ops = { - .vidioc_querycap = pxp_querycap, + .vidioc_querycap = pxp_querycap, - .vidioc_reqbufs = pxp_reqbufs, - .vidioc_querybuf = pxp_querybuf, - .vidioc_qbuf = pxp_qbuf, - .vidioc_dqbuf = pxp_dqbuf, + .vidioc_reqbufs = pxp_reqbufs, + .vidioc_querybuf = pxp_querybuf, + .vidioc_qbuf = pxp_qbuf, + .vidioc_dqbuf = pxp_dqbuf, - .vidioc_streamon = pxp_streamon, - .vidioc_streamoff = pxp_streamoff, + .vidioc_streamon = pxp_streamon, + .vidioc_streamoff = pxp_streamoff, - .vidioc_enum_output = pxp_enumoutput, - .vidioc_g_output = pxp_g_output, - .vidioc_s_output = pxp_s_output, + .vidioc_enum_output = pxp_enumoutput, + .vidioc_g_output = pxp_g_output, + .vidioc_s_output = pxp_s_output, - .vidioc_enum_fmt_vid_out = pxp_enum_fmt_video_output, - .vidioc_try_fmt_vid_out = pxp_try_fmt_video_output, - .vidioc_g_fmt_vid_out = pxp_g_fmt_video_output, - .vidioc_s_fmt_vid_out = pxp_s_fmt_video_output, + .vidioc_enum_fmt_vid_out = pxp_enum_fmt_video_output, + .vidioc_try_fmt_vid_out = pxp_try_fmt_video_output, + .vidioc_g_fmt_vid_out = pxp_g_fmt_video_output, + .vidioc_s_fmt_vid_out = pxp_s_fmt_video_output, - .vidioc_try_fmt_vid_out_overlay = pxp_try_fmt_output_overlay, - .vidioc_g_fmt_vid_out_overlay = pxp_g_fmt_output_overlay, - .vidioc_s_fmt_vid_out_overlay = pxp_s_fmt_output_overlay, + .vidioc_try_fmt_vid_out_overlay = pxp_try_fmt_output_overlay, + .vidioc_g_fmt_vid_out_overlay = pxp_g_fmt_output_overlay, + .vidioc_s_fmt_vid_out_overlay = pxp_s_fmt_output_overlay, - .vidioc_g_fbuf = pxp_g_fbuf, - .vidioc_s_fbuf = pxp_s_fbuf, + .vidioc_g_fbuf = pxp_g_fbuf, + .vidioc_s_fbuf = pxp_s_fbuf, - .vidioc_g_crop = pxp_g_crop, - .vidioc_s_crop = pxp_s_crop, + .vidioc_g_crop = pxp_g_crop, + .vidioc_s_crop = pxp_s_crop, - .vidioc_queryctrl = pxp_queryctrl, - .vidioc_g_ctrl = pxp_g_ctrl, - .vidioc_s_ctrl = pxp_s_ctrl, + .vidioc_queryctrl = pxp_queryctrl, + .vidioc_g_ctrl = pxp_g_ctrl, + .vidioc_s_ctrl = pxp_s_ctrl, }; static const struct video_device pxp_template = { - .name = "PxP", - .vfl_type = VID_TYPE_OVERLAY | - VID_TYPE_CLIPPING | - VID_TYPE_SCALES, - .fops = &pxp_fops, - .release = pxp_release, - .minor = -1, - .ioctl_ops = &pxp_ioctl_ops, + .name = "PxP", + .vfl_type = VID_TYPE_OVERLAY | VID_TYPE_CLIPPING | VID_TYPE_SCALES, + .fops = &pxp_fops, + .release = pxp_release, + .minor = -1, + .ioctl_ops = &pxp_ioctl_ops, }; static irqreturn_t pxp_irq(int irq, void *dev_id) @@ -1176,16 +1169,14 @@ static irqreturn_t pxp_irq(int irq, void *dev_id) spin_lock_irqsave(&pxp->lock, flags); - __raw_writel(BM_PXP_STAT_IRQ, HW_PXP_STAT_CLR_ADDR); + __raw_writel(BM_PXP_STAT_IRQ, PXP_BASE_ADDR + HW_PXP_STAT_CLR); if (list_empty(&pxp->outq)) { pr_warning("irq: outq empty!!!\n"); goto out; } - vb = list_entry(pxp->outq.next, - struct videobuf_buffer, - queue); + vb = list_entry(pxp->outq.next, struct videobuf_buffer, queue); list_del_init(&vb->queue); vb->state = VIDEOBUF_DONE; @@ -1241,8 +1232,9 @@ static int pxp_probe(struct platform_device *pdev) pxp->irq = irq; pxp->regs_virt = dma_alloc_coherent(NULL, - PAGE_ALIGN(sizeof(struct pxp_registers)), - &pxp->regs_phys, GFP_KERNEL); + PAGE_ALIGN(sizeof + (struct pxp_registers)), + &pxp->regs_phys, GFP_KERNEL); if (pxp->regs_virt == NULL) { dev_err(&pdev->dev, "failed to allocate pxp_register object\n"); err = -ENOMEM; @@ -1263,7 +1255,7 @@ static int pxp_probe(struct platform_device *pdev) goto freepxp; } - pxp->regs = (void __iomem *)res->start; /* it is already ioremapped */ + pxp->regs = (void __iomem *)res->start; /* it is already ioremapped */ pxp->pdev = pdev; err = request_irq(pxp->irq, pxp_irq, 0, PXP_DRIVER_NAME, pxp); @@ -1327,7 +1319,7 @@ static int __devexit pxp_remove(struct platform_device *pdev) if (pxp->regs_virt) dma_free_coherent(0, PAGE_ALIGN(sizeof(struct pxp_registers)), - pxp->regs_virt, pxp->regs_phys); + pxp->regs_virt, pxp->regs_phys); kfree(pxp->outb); kfree(pxp); @@ -1339,19 +1331,23 @@ static int pxp_suspend(struct platform_device *pdev, pm_message_t state) { int i; - while (__raw_readl(HW_PXP_CTRL_ADDR) & BM_PXP_CTRL_ENABLE) + while (__raw_readl(PXP_BASE_ADDR + HW_PXP_CTRL) & BM_PXP_CTRL_ENABLE) ; for (i = 0; i < REGS1_NUMS; i++) - regs1[i] = __raw_readl(HW_PXP_CTRL_ADDR + REG_OFFSET * i); + regs1[i] = + __raw_readl(PXP_BASE_ADDR + HW_PXP_CTRL + REG_OFFSET * i); for (i = 0; i < REGS2_NUMS; i++) - regs2[i] = __raw_readl(HW_PXP_PAGETABLE_ADDR + REG_OFFSET * i); + regs2[i] = + __raw_readl(PXP_BASE_ADDR + HW_PXP_S0COLORKEYLOW + + REG_OFFSET * i); for (i = 0; i < REGS3_NUMS; i++) - regs3[i] = __raw_readl(HW_PXP_OLn_ADDR(0) + REG_OFFSET * i); + regs3[i] = + __raw_readl(PXP_BASE_ADDR + HW_PXP_OLn(0) + REG_OFFSET * i); - __raw_writel(BM_PXP_CTRL_SFTRST, HW_PXP_CTRL_ADDR); + __raw_writel(BM_PXP_CTRL_SFTRST, PXP_BASE_ADDR + HW_PXP_CTRL); return 0; } @@ -1361,16 +1357,20 @@ static int pxp_resume(struct platform_device *pdev) int i; /* Pull PxP out of reset */ - __raw_writel(0, HW_PXP_CTRL_ADDR); + __raw_writel(0, PXP_BASE_ADDR + HW_PXP_CTRL); for (i = 0; i < REGS1_NUMS; i++) - __raw_writel(regs1[i], HW_PXP_CTRL_ADDR + REG_OFFSET * i); + __raw_writel(regs1[i], + PXP_BASE_ADDR + HW_PXP_CTRL + REG_OFFSET * i); for (i = 0; i < REGS2_NUMS; i++) - __raw_writel(regs2[i], HW_PXP_PAGETABLE_ADDR + REG_OFFSET * i); + __raw_writel(regs2[i], + PXP_BASE_ADDR + HW_PXP_S0COLORKEYLOW + + REG_OFFSET * i); for (i = 0; i < REGS3_NUMS; i++) - __raw_writel(regs3[i], HW_PXP_OLn_ADDR(0) + REG_OFFSET * i); + __raw_writel(regs3[i], + PXP_BASE_ADDR + HW_PXP_OLn(0) + REG_OFFSET * i); return 0; } @@ -1380,16 +1380,15 @@ static int pxp_resume(struct platform_device *pdev) #endif static struct platform_driver pxp_driver = { - .driver = { - .name = PXP_DRIVER_NAME, - }, - .probe = pxp_probe, - .remove = __exit_p(pxp_remove), - .suspend = pxp_suspend, - .resume = pxp_resume, + .driver = { + .name = PXP_DRIVER_NAME, + }, + .probe = pxp_probe, + .remove = __exit_p(pxp_remove), + .suspend = pxp_suspend, + .resume = pxp_resume, }; - static int __devinit pxp_init(void) { return platform_driver_register(&pxp_driver); diff --git a/drivers/media/video/pxp.h b/drivers/media/video/pxp.h index 11b41dcc6ade..14ce76ced9f5 100644 --- a/drivers/media/video/pxp.h +++ b/drivers/media/video/pxp.h @@ -1,19 +1,24 @@ /* - * Freescale STMP378X PxP driver + * Freescale MXS PxP driver * * Author: Matt Porter <mporter@embeddedalley.com> * * Copyright 2008-2010 Freescale Semiconductor, Inc. * Copyright 2008-2009 Embedded Alley Solutions, Inc All Rights Reserved. - */ - -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ struct pxp_overlay_registers { @@ -125,6 +130,6 @@ struct pxp_data_format { u32 ctrl_s0_fmt; }; -extern int stmp3xxxfb_get_info(struct fb_var_screeninfo *var, +extern int mxsfb_get_info(struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix); -extern void stmp3xxxfb_cfg_pxp(int enable, dma_addr_t pxp_phys); +extern void mxsfb_cfg_pxp(int enable, dma_addr_t pxp_phys); |