commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=d05674da767f2dc3e0df43f17ca53c2e1fc2191b branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk
let board config to decide ppi operation mode Signed-off-by: Scott Jiang <[email protected]> --- arch/blackfin/mach-bf537/boards/stamp.c | 4 ++ drivers/media/video/blackfin/bfin_capture.c | 2 +- drivers/media/video/blackfin/ppi.c | 66 ++++++++++++++++++++++- drivers/media/video/blackfin/ppi.h | 56 -------------------- include/media/blackfin/bfin_capture.h | 8 ++-- include/media/blackfin/ppi.h | 76 +++++++++++++++++++++++++++ 6 files changed, 149 insertions(+), 63 deletions(-) diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 2f7c712..688f8e3 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c @@ -1593,6 +1593,8 @@ static struct platform_device bfin_ppi_device = { || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE) #include <media/blackfin/bfin_capture.h> +#if defined(CONFIG_VIDEO_VS6624) \ + || defined(CONFIG_VIDEO_VS6624__MODULE) static struct v4l2_input vs6624_inputs[] = { { .index = 0, @@ -1618,7 +1620,9 @@ static struct bfin_capture_config bfin_capture_data = { .board_info = { I2C_BOARD_INFO("vs6624", 0x10) }, + .flags = PPI_FLAG_PACK_EN, }; +#endif static struct platform_device bfin_capture_device = { .name = "bfin_capture", diff --git a/drivers/media/video/blackfin/bfin_capture.c b/drivers/media/video/blackfin/bfin_capture.c index df13447..4b25629 100644 --- a/drivers/media/video/blackfin/bfin_capture.c +++ b/drivers/media/video/blackfin/bfin_capture.c @@ -46,7 +46,6 @@ #include <asm/dma.h> #include <media/blackfin/bfin_capture.h> -#include "ppi.h" #define CAPTURE_DRV_NAME "bfin_capture" #define BCAP_MIN_NUM_BUF 3 @@ -351,6 +350,7 @@ static int bcap_start_streaming(struct vb2_queue *vq) params.width = bcap_dev->fmt.width; params.height = bcap_dev->fmt.height; params.bpp = bcap_dev->bpp; + params.flags = bcap_dev->cfg->flags; ret = ppi->ops->set_params(ppi, ¶ms); if (ret < 0) { v4l2_err(&bcap_dev->v4l2_dev, diff --git a/drivers/media/video/blackfin/ppi.c b/drivers/media/video/blackfin/ppi.c index 324bc34..ac6f5f8 100644 --- a/drivers/media/video/blackfin/ppi.c +++ b/drivers/media/video/blackfin/ppi.c @@ -28,7 +28,7 @@ #include <asm/blackfin.h> #include <asm/portmux.h> -#include "ppi.h" +#include <media/blackfin/ppi.h> #define regr(reg) readw((reg) + ppi_base) #define regw(value, reg) writew(value, ((reg) + ppi_base)) @@ -135,6 +135,8 @@ static int ppi_stop(struct ppi_if *intf) static int ppi_set_params(struct ppi_if *intf, struct ppi_params *params) { + int ck_skip = 0; + intf->bytes_per_line = params->width * params->bpp; intf->lines_per_frame = params->height; @@ -147,7 +149,67 @@ static int ppi_set_params(struct ppi_if *intf, struct ppi_params *params) set_dma_config(intf->dma_ch, intf->dma_config); /* config PPI */ - intf->ppi_control = (PACK_EN | DLEN_8 | 0x000c | 0x0020); + if (params->flags & PPI_FLAG_TX_MOD) { + /* ppi in transmit mode */ + intf->ppi_control = 0x0002; + /* set xfer type */ + if (!(params->flags & PPI_FLAG_NO_SYNC)) + intf->ppi_control |= 0x000c; + /* set port cfg */ + else if (params->flags & PPI_FLAG_ONE_SYNC) + intf->ppi_control |= 0x0000; + else if (params->flags & PPI_FLAG_FS2_ASSERT) + intf->ppi_control |= 0x0030; + else + intf->ppi_control |= 0x0010; + } else { + /* ppi in receive mode */ + intf->ppi_control = 0x0000; + /* set xfer type */ + if (params->flags & PPI_FLAG_BT656) { + if (params->flags & PPI_FLAG_ACTIVE_FLD) + intf->ppi_control |= 0x0000; + else if (params->flags & PPI_FLAG_ENTIRE_FLD) + intf->ppi_control |= 0x0004; + else + intf->ppi_control |= 0x0008; + ck_skip = 1; + } else { + intf->ppi_control |= 0x000C; + /* set port cfg */ + if (params->flags & PPI_FLAG_NO_SYNC) + intf->ppi_control |= 0x0030; + else if (params->flags & PPI_FLAG_ONE_SYNC) { + intf->ppi_control |= 0x0000; + ck_skip = 1; + } else if (params->flags & PPI_FLAG_INTER_SYNC) + /* 2 or 3 internal frame syncs */ + intf->ppi_control |= 0x0010; + else { + /* 2 or 3 external frame syncs */ + intf->ppi_control |= 0x0020; + ck_skip = 1; + } + } + } + if (params->flags & PPI_FLAG_FLD_SEL) + intf->ppi_control |= FLD_SEL; + if (params->flags & PPI_FLAG_PACK_EN) + intf->ppi_control |= PACK_EN; + if (params->flags & PPI_FLAG_DMA32) + intf->ppi_control |= DMA32; + if (params->flags & PPI_FLAG_CLK_FALL) + intf->ppi_control |= POLC; + if (params->flags & PPI_FLAG_FS_FALL) + intf->ppi_control |= POLS; + if (ck_skip) { + if (params->flags & PPI_FLAG_SKIP_EN) { + intf->ppi_control |= SKIP_EN; + if (params->flags & PPI_FLAG_SKIP_EVEN) + intf->ppi_control |= SKIP_EO; + } + } + intf->ppi_control |= DLEN_8; regw(intf->ppi_control, REG_PPI_CONTROL); regw(intf->bytes_per_line - 1, REG_PPI_COUNT); regw(intf->lines_per_frame, REG_PPI_FRAME); diff --git a/drivers/media/video/blackfin/ppi.h b/drivers/media/video/blackfin/ppi.h deleted file mode 100644 index 0661faf..0000000 --- a/drivers/media/video/blackfin/ppi.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Analog Devices PPI header file - * - * Copyright (c) 2011 Scott Jiang <[email protected]> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _PPI_H_ -#define _PPI_H_ - -#include <linux/interrupt.h> - -struct ppi_if; - -struct ppi_params { - int width; - int height; - int bpp; -}; - -struct ppi_ops { - int (*attach_irq)(struct ppi_if *intf, irq_handler_t handler); - void (*detach_irq)(struct ppi_if *intf); - int (*start)(struct ppi_if *intf); - int (*stop)(struct ppi_if *intf); - int (*set_params)(struct ppi_if *intf, struct ppi_params *params); - void (*update_addr)(struct ppi_if *intf, unsigned long addr); -}; - -struct ppi_if { - int dma_ch; - int irq_err; - int dma_config; - int bytes_per_line; - int lines_per_frame; - unsigned short ppi_control; - const unsigned short *pin_req; - struct ppi_ops *ops; - void *priv; -}; - -struct ppi_if *bfin_get_ppi_if(void); - -#endif diff --git a/include/media/blackfin/bfin_capture.h b/include/media/blackfin/bfin_capture.h index 639690f..a62bc1c 100644 --- a/include/media/blackfin/bfin_capture.h +++ b/include/media/blackfin/bfin_capture.h @@ -1,11 +1,11 @@ #ifndef _BFIN_CAPTURE_H_ #define _BFIN_CAPTURE_H_ -#ifdef __KERNEL__ - #include <linux/i2c.h> #include <linux/videodev2.h> +#include <media/blackfin/ppi.h> + struct bcap_route { u32 input; u32 output; @@ -24,8 +24,8 @@ struct bfin_capture_config { int i2c_adapter_id; /* i2c subdevice board info */ struct i2c_board_info board_info; + /* ppi control flag */ + unsigned long flags; }; #endif - -#endif diff --git a/include/media/blackfin/ppi.h b/include/media/blackfin/ppi.h new file mode 100644 index 0000000..75ca5b8 --- /dev/null +++ b/include/media/blackfin/ppi.h @@ -0,0 +1,76 @@ +/* + * Analog Devices PPI header file + * + * Copyright (c) 2011 Scott Jiang <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _PPI_H_ +#define _PPI_H_ + +#include <linux/interrupt.h> + +/* control flags*/ +#define PPI_FLAG_TX_MOD 0x0001 /* ppi in transmit mode */ +#define PPI_FLAG_ACTIVE_FLD 0x0002 /* BT656 active field only */ +#define PPI_FLAG_ENTIRE_FLD 0x0004 /* BT656 entire field */ +#define PPI_FLAG_VBI 0x0008 /* BT656 VBI only */ +#define PPI_FLAG_NO_SYNC 0x0010 /* no frame syncs */ +#define PPI_FLAG_ONE_SYNC 0x0020 /* one frame sync */ +#define PPI_FLAG_INTER_SYNC 0x0040 /* internal frame sync */ +#define PPI_FLAG_FS2_ASSERT 0x0080 /* FS3 sync to FS2 assertion */ +#define PPI_FLAG_FLD_SEL 0x0100 /* select both fields or internal trigger */ +#define PPI_FLAG_PACK_EN 0x0200 /* packing mode enable */ +#define PPI_FLAG_DMA32 0x0400 /* 32-bit DMA width enable */ +#define PPI_FLAG_SKIP_EN 0x0800 /* skipping enabled */ +#define PPI_FLAG_SKIP_EVEN 0x1000 /* skip even-numbered elements */ +#define PPI_FLAG_CLK_FALL 0x2000 /* sample data on falling edge of PPI_CLK */ +#define PPI_FLAG_FS_FALL 0x4000 /* FS1 and FS2 are falling edge asserted */ +#define PPI_FLAG_BT656 \ + (PPI_FLAG_ACTIVE_FLD | PPI_FLAG_ENTIRE_FLD | PPI_FLAG_VBI) + +struct ppi_if; + +struct ppi_params { + int width; + int height; + int bpp; + unsigned long flags; +}; + +struct ppi_ops { + int (*attach_irq)(struct ppi_if *intf, irq_handler_t handler); + void (*detach_irq)(struct ppi_if *intf); + int (*start)(struct ppi_if *intf); + int (*stop)(struct ppi_if *intf); + int (*set_params)(struct ppi_if *intf, struct ppi_params *params); + void (*update_addr)(struct ppi_if *intf, unsigned long addr); +}; + +struct ppi_if { + int dma_ch; + int irq_err; + int dma_config; + int bytes_per_line; + int lines_per_frame; + unsigned short ppi_control; + const unsigned short *pin_req; + struct ppi_ops *ops; + void *priv; +}; + +struct ppi_if *bfin_get_ppi_if(void); + +#endif
_______________________________________________ Linux-kernel-commits mailing list [email protected] https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits
