Martin,
As I am working on review the SVN patch for upstream mainline, I will
give some comments about this patch.
On Tue, 2007-12-11 at 00:24 +0800, [EMAIL PROTECTED] wrote:
> Revision
> 4017
> Author
> strubi
> Date
> 2007-12-10 10:24:25 -0600 (Mon, 10 Dec 2007)
> Log Message
> Added OV9655 sensor basic code (SRV1 board supply), added Minotaur BSP.
> Diffstat
> arch/blackfin/mach-bf537/boards/Kconfig | 6
> arch/blackfin/mach-bf537/boards/Makefile | 1
> arch/blackfin/mach-bf537/boards/minotaur.c | 317 ++++++++++++++++++++++
This big patch can be divided into 2 parts.
1. patch to add new Minotaur BSP
2. patch to add new OV9655 sensor basic code
> drivers/media/video/blackfin/Kconfig | 8
> drivers/media/video/blackfin/Makefile | 3
> drivers/media/video/blackfin/blackfin_cam.c | 4
> drivers/media/video/blackfin/ov9655.c | 396
> ++++++++++++++++++++++++++++
> drivers/media/video/blackfin/ov9655.h | 75 +++++
> 8 files changed, 810 insertions(+)
> Modified Paths
> * trunk/arch/blackfin/mach-bf537/boards/Kconfig
> * trunk/arch/blackfin/mach-bf537/boards/Makefile
> * trunk/drivers/media/video/blackfin/Kconfig
> * trunk/drivers/media/video/blackfin/Makefile
> * trunk/drivers/media/video/blackfin/blackfin_cam.c
> Added Paths
> * trunk/arch/blackfin/mach-bf537/boards/minotaur.c
> * trunk/drivers/media/video/blackfin/ov9655.c
> * trunk/drivers/media/video/blackfin/ov9655.h
> Diff
> Modified: trunk/arch/blackfin/mach-bf537/boards/Kconfig (4016 => 4017)
>
> --- trunk/arch/blackfin/mach-bf537/boards/Kconfig 2007-12-10 14:59:47 UTC
> (rev 4016)
> +++ trunk/arch/blackfin/mach-bf537/boards/Kconfig 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -21,6 +21,12 @@
> help
> PNAV board support.
>
> +config CAMSIG_MINOTAUR
> + bool "Cambridge Signal Processing LTD Minotaur"
> + depends on (BF537)
> + help
> + Board supply package for CSP Minotaur
> +
> config GENERIC_BF537_BOARD
> bool "Generic"
> help
> Modified: trunk/arch/blackfin/mach-bf537/boards/Makefile (4016 =>
> 4017)
>
> --- trunk/arch/blackfin/mach-bf537/boards/Makefile 2007-12-10 14:59:47 UTC
> (rev 4016)
> +++ trunk/arch/blackfin/mach-bf537/boards/Makefile 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -6,3 +6,4 @@
> obj-$(CONFIG_BFIN537_STAMP) += stamp.o led.o
> obj-$(CONFIG_BFIN537_BLUETECHNIX_CM) += cm_bf537.o
> obj-$(CONFIG_PNAV10) += pnav10.o
> +obj-$(CONFIG_CAMSIG_MINOTAUR) += minotaur.o
> Added: trunk/arch/blackfin/mach-bf537/boards/minotaur.c (0 => 4017)
>
> --- trunk/arch/blackfin/mach-bf537/boards/minotaur.c
> (rev 0)
> +++ trunk/arch/blackfin/mach-bf537/boards/minotaur.c 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -0,0 +1,317 @@
> +/*
> + */
> +
> +#include <linux/device.h>
> +#include <linux/platform_device.h>
> +#include <linux/mtd/mtd.h>
> +#include <linux/mtd/partitions.h>
> +#include <linux/spi/spi.h>
> +#include <linux/spi/flash.h>
> +#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
> +#include <linux/usb_isp1362.h>
<linux/usb_isp1362.h> ---> <linux/usb/isp1362.h>
> +#endif
> +#include <linux/pata_platform.h>
> +#include <linux/irq.h>
> +#include <linux/interrupt.h>
> +#include <linux/usb_sl811.h>
<linux/usb_sl811.h> ---> <linux/usb/sl811.h>
> +#include <asm/dma.h>
> +#include <asm/bfin5xx_spi.h>
> +#include <asm/reboot.h>
> +#include <linux/spi/ad7877.h>
> +
> +/*
> + * Name the Board for the /proc/cpuinfo
> + */
> +char *bfin_board_name = "CamSig Minotaur BF537";
> +
> +#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
> +static struct resource bfin_pcmcia_cf_resources[] = {
> + {
> + .start = 0x20310000, /* IO PORT */
> + .end = 0x20312000,
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x20311000, /* Attribute Memory */
> + .end = 0x20311FFF,
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = IRQ_PF4,
> + .end = IRQ_PF4,
> + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
> + }, {
> + .start = IRQ_PF6, /* Card Detect PF6 */
> + .end = IRQ_PF6,
> + .flags = IORESOURCE_IRQ,
> + },
> +};
> +
> +static struct platform_device bfin_pcmcia_cf_device = {
> + .name = "bfin_cf_pcmcia",
> + .id = -1,
> + .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
> + .resource = bfin_pcmcia_cf_resources,
> +};
> +#endif
> +
> +#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
> +static struct platform_device rtc_device = {
> + .name = "rtc-bfin",
> + .id = -1,
> +};
> +#endif
> +
> +#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
> +static struct platform_device bfin_mac_device = {
> + .name = "bfin_mac",
> +};
> +#endif
> +
> +#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
> +static struct resource net2272_bfin_resources[] = {
> + {
> + .start = 0x20300000,
> + .end = 0x20300000 + 0x100,
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = IRQ_PF7,
> + .end = IRQ_PF7,
> + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
> + },
> +};
> +
> +static struct platform_device net2272_bfin_device = {
> + .name = "net2272",
> + .id = -1,
> + .num_resources = ARRAY_SIZE(net2272_bfin_resources),
> + .resource = net2272_bfin_resources,
> +};
> +#endif
> +
> +#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
> +/* all SPI peripherals info goes here */
> +
> +#if defined(CONFIG_MTD_M25P80) \
> + || defined(CONFIG_MTD_M25P80_MODULE)
> +
> +/* Partition sizes */
> +#define FLASH_SIZE 0x00400000
> +#define PSIZE_UBOOT 0x00030000
> +#define PSIZE_INITRAMFS 0x00240000
> +
> +static struct mtd_partition bfin_spi_flash_partitions[] = {
> + {
> + .name = "uboot",
> + .size = PSIZE_UBOOT,
> + .offset = 0x000000,
> + .mask_flags = MTD_CAP_ROM
> + }, {
> + .name = "initramfs",
> + .size = PSIZE_INITRAMFS,
> + .offset = PSIZE_UBOOT
> + }, {
> + .name = "opt",
> + .size = FLASH_SIZE - (PSIZE_UBOOT + PSIZE_INITRAMFS),
> + .offset = PSIZE_UBOOT + PSIZE_INITRAMFS,
> + }
> +};
> +
> +static struct flash_platform_data bfin_spi_flash_data = {
> + .name = "m25p80",
> + .parts = bfin_spi_flash_partitions,
> + .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
> + .type = "m25p64",
> +};
> +
> +/* SPI flash chip (m25p64) */
> +static struct bfin5xx_spi_chip spi_flash_chip_info = {
> + .enable_dma = 0, /* use dma transfer with this chip*/
> + .bits_per_word = 8,
> +};
> +#endif
> +
> +#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
> +static struct bfin5xx_spi_chip spi_mmc_chip_info = {
> + .enable_dma = 1,
> + .bits_per_word = 8,
> +};
> +#endif
> +
> +static struct spi_board_info bfin_spi_board_info[] __initdata = {
> +#if defined(CONFIG_MTD_M25P80) \
> + || defined(CONFIG_MTD_M25P80_MODULE)
> + {
> + /* the modalias must be the same as spi device driver name */
> + .modalias = "m25p80", /* Name of spi_driver for this device */
> + .max_speed_hz = 25000000, /* max spi clock (SCK) speed in
> HZ */
> + .bus_num = 0, /* Framework bus number */
> + .chip_select = 1, /* Framework chip select. On STAMP537 it is
> SPISSEL1*/
> + .platform_data = &bfin_spi_flash_data,
> + .controller_data = &spi_flash_chip_info,
> + .mode = SPI_MODE_3,
> + },
> +#endif
> +
> +#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
> + {
> + .modalias = "spi_mmc_dummy",
> + .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ
> */
> + .bus_num = 0,
> + .chip_select = 0,
> + .platform_data = NULL,
> + .controller_data = &spi_mmc_chip_info,
> + .mode = SPI_MODE_3,
> + },
> + {
> + .modalias = "spi_mmc",
> + .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ
> */
> + .bus_num = 0,
> + .chip_select = CONFIG_SPI_MMC_CS_CHAN,
> + .platform_data = NULL,
> + .controller_data = &spi_mmc_chip_info,
> + .mode = SPI_MODE_3,
> + },
> +#endif
> +};
> +
> +/* SPI controller data */
> +static struct bfin5xx_spi_master bfin_spi0_info = {
> + .num_chipselect = 8,
> + .enable_dma = 1, /* master has the ability to do dma transfer */
> +};
> +
> +/* SPI (0) */
> +static struct resource bfin_spi0_resource[] = {
> + [0] = {
> + .start = SPI0_REGBASE,
> + .end = SPI0_REGBASE + 0xFF,
> + .flags = IORESOURCE_MEM,
> + },
> + [1] = {
> + .start = CH_SPI,
> + .end = CH_SPI,
> + .flags = IORESOURCE_IRQ,
> + },
> +};
> +
> +static struct platform_device bfin_spi0_device = {
> + .name = "bfin-spi",
> + .id = 0, /* Bus number */
> + .num_resources = ARRAY_SIZE(bfin_spi0_resource),
> + .resource = bfin_spi0_resource,
> + .dev = {
> + .platform_data = &bfin_spi0_info, /* Passed to driver */
> + },
> +};
> +#endif /* spi master and devices */
> +
> +#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
> +static struct resource bfin_uart_resources[] = {
> + {
> + .start = 0xFFC00400,
> + .end = 0xFFC004FF,
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0xFFC02000,
> + .end = 0xFFC020FF,
> + .flags = IORESOURCE_MEM,
> + },
> +};
> +
> +static struct platform_device bfin_uart_device = {
> + .name = "bfin-uart",
> + .id = 1,
> + .num_resources = ARRAY_SIZE(bfin_uart_resources),
> + .resource = bfin_uart_resources,
> +};
> +#endif
> +
> +#if defined(CONFIG_I2C_BLACKFIN_TWI) ||
> defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
> +static struct resource bfin_twi0_resource[] = {
> + [0] = {
> + .start = TWI0_REGBASE,
> + .end = TWI0_REGBASE + 0xFF,
> + .flags = IORESOURCE_MEM,
> + },
> + [1] = {
> + .start = IRQ_TWI,
> + .end = IRQ_TWI,
> + .flags = IORESOURCE_IRQ,
> + },
> +};
> +
> +static struct platform_device i2c_bfin_twi_device = {
> + .name = "i2c-bfin-twi",
> + .id = 0,
> + .num_resources = ARRAY_SIZE(bfin_twi0_resource),
> + .resource = bfin_twi0_resource,
> +};
> +#endif
> +
> +#if defined(CONFIG_SERIAL_BFIN_SPORT) ||
> defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
> +static struct platform_device bfin_sport0_uart_device = {
> + .name = "bfin-sport-uart",
> + .id = 0,
> +};
> +
> +static struct platform_device bfin_sport1_uart_device = {
> + .name = "bfin-sport-uart",
> + .id = 1,
> +};
> +#endif
> +
> +static struct platform_device *minotaur_devices[] __initdata = {
> +#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
> + &bfin_pcmcia_cf_device,
> +#endif
> +
> +#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
> + &rtc_device,
> +#endif
> +
> +#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
> + &bfin_mac_device,
> +#endif
> +
> +#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
> + &net2272_bfin_device,
> +#endif
> +
> +#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
> + &bfin_spi0_device,
> +#endif
> +
> +#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
> + &bfin_uart_device,
> +#endif
> +
> +#if defined(CONFIG_I2C_BLACKFIN_TWI) ||
> defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
> + &i2c_bfin_twi_device,
> +#endif
> +
> +#if defined(CONFIG_SERIAL_BFIN_SPORT) ||
> defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
> + &bfin_sport0_uart_device,
> + &bfin_sport1_uart_device,
> +#endif
> +
> +};
> +
> +static int __init minotaur_init(void)
> +{
> + printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
> + platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
> +#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
> + spi_register_board_info(bfin_spi_board_info,
> + ARRAY_SIZE(bfin_spi_board_info));
> +#endif
> +
> + return 0;
> +}
> +
> +arch_initcall(minotaur_init);
> +
> +void native_machine_restart(char *cmd)
> +{
> + /* workaround reboot hang when booting from SPI */
> + if ((bfin_read_SYSCR() & 0x7) == 0x3)
> + bfin_gpio_reset_spi0_ssel1();
> +}
> Modified: trunk/drivers/media/video/blackfin/Kconfig (4016 => 4017)
>
> --- trunk/drivers/media/video/blackfin/Kconfig 2007-12-10 14:59:47 UTC
> (rev 4016)
> +++ trunk/drivers/media/video/blackfin/Kconfig 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -40,4 +40,12 @@
> help
> ST VS6624 Sensor Support
>
> +config OV9655
> + bool "OV9655"
> + depends on VIDEO_BLACKFIN_CAM && EXPERIMENTAL
> + help
> + Omnivision OV9655 Sensor Support
> + This is work in progress. NOT YET COMPLETE.
> +
> +
Can make these camera chip driver more generic and move them to
driver/media/video?
So the code can be shared by other platform and can be merged to
upstream mainline more easily.
Because I wanna push these Blackfin video camera code to upstream
mainline after our 08R1 release.
How do you think, Michael?
> endchoice
> Modified: trunk/drivers/media/video/blackfin/Makefile (4016 => 4017)
>
> --- trunk/drivers/media/video/blackfin/Makefile 2007-12-10 14:59:47 UTC
> (rev 4016)
> +++ trunk/drivers/media/video/blackfin/Makefile 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -1,4 +1,7 @@
> +
> bfin-cam-sensor-$(CONFIG_VS6524) := vs6524.o
> bfin-cam-sensor-$(CONFIG_VS6624) := vs6624.o
> bfin-cam-sensor-$(CONFIG_MT9V022) := mt9v022.o
> +bfin-cam-sensor-$(CONFIG_OV9655) := ov9655.o
> obj-$(CONFIG_VIDEO_BLACKFIN_CAM) := blackfin_cam.o $(bfin-cam-sensor-y)
> +obj-$(CONFIG_VIDEO_BLACKFIN_MT9M001) += mt9m001.o
> Modified: trunk/drivers/media/video/blackfin/blackfin_cam.c (4016 =>
> 4017)
>
> --- trunk/drivers/media/video/blackfin/blackfin_cam.c 2007-12-10 14:59:47 UTC
> (rev 4016)
> +++ trunk/drivers/media/video/blackfin/blackfin_cam.c 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -73,7 +73,11 @@
> #include "mt9v022.h"
> #endif
>
> +#ifdef CONFIG_OV9655
> +#include "ov9655.h"
> +#endif
>
> +
> #ifdef USE_GPIO
> #define GPIO_SET_VALUE(x,y) gpio_set_value(x,y)
> #else
> Added: trunk/drivers/media/video/blackfin/ov9655.c (0 => 4017)
>
> --- trunk/drivers/media/video/blackfin/ov9655.c
> (rev 0)
> +++ trunk/drivers/media/video/blackfin/ov9655.c 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -0,0 +1,396 @@
> +/*
> + * File: drivers/media/video/blackfin/ov9655.c
> + * Based on:
> + * Author: Michael Hennerich <[EMAIL PROTECTED]>
> + *
As Michael is the author, why Michael did not send out this driver?
Or you should use your name for the kernel world, like
Martin Strubel <[EMAIL PROTECTED]>
> + * Created:
> + * Description: Command driver for Omnivision OV9655 sensor
> + *
> + *
> + * Modified:
> + * 10/2007 Omnivision 9655 basic image driver
> + *
> + * Bugs: Enter bugs at http://blackfin.uclinux.org/
> + *
> + * 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, see the file COPYING, or write
> + * to the Free Software Foundation, Inc.,
> + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/errno.h>
> +#include <linux/fs.h>
> +#include <linux/i2c.h>
> +#include <linux/i2c-dev.h>
> +#include <linux/init.h>
> +#include <linux/jiffies.h>
> +#include <linux/kernel.h>
> +#include <linux/mm.h>
> +#include <linux/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/poll.h>
> +#include <linux/proc_fs.h>
> +#include <linux/sched.h>
> +#include <linux/slab.h>
> +#include <linux/spinlock.h>
> +#include <linux/time.h>
> +#include <linux/timex.h>
> +#include <linux/wait.h>
> +#include <media/v4l2-dev.h>
> +
> +#include "ov9655.h"
> +
> +static char myconfig[] = {
Shall we choose more meaningful name of data structures or functions?
I found many my*() things in this driver.
> + 0x11, 0x81,
> +
> +};
> +
> +static DEFINE_MUTEX(ov9655_sysfs_lock);
> +
> +static int ReadWord(struct i2c_client *client, unsigned char offset, u16
> *data)
If we follow the kernel or UNIX coding style, please change "ReadWord"
to "read_word"
> +{
> + u8 buf[2];
> +
> + BUG_ON(client == NULL);
> +
> + i2c_smbus_write_byte(client, offset);
> + i2c_master_recv(client, buf, 1);
> +
> + *data = buf[0];
> +
> + return 0;
> +}
> +
> +static int WriteWord(struct i2c_client *client,
> + unsigned char offset, unsigned short data)
ditto
> +{
> + u8 buf[2];
> +
> + BUG_ON(client == NULL);
> +
> + buf[0] = offset;
> + buf[1] = data >> 8;
> +
> + i2c_master_send(client, buf, 2);
> +
> + return 0;
> +}
> +
> +static unsigned short get_reg(struct i2c_client *client, unsigned char
> offset)
> +{
> + u16 buf[1];
> +
> + ReadWord(client, offset, &buf[0]);
> +
> + return buf[0];
> +}
> +
> +static int my_probe(struct i2c_client *client)
s/my_/ov9655_/g
> +{
> +
> +/*
> + u8 buf[2];
> +
> + ReadWord(client, DEVICEID_MSB, &buf[0]);
> +
> + if (((buf[0] << 8) | (buf[1] & 0xFF)) == MT9V022_ID)
> + return 0;
> +
> + return -ENODEV;
> +*/
> + return 0;
> +
> +}
> +
> +static int my_set_pixfmt(struct i2c_client *client, u32 arg)
> +{
> + return 0;
> +}
> +
> +static int my_set_framerate(struct i2c_client *client, u32 arg)
> +{
> +
> + return -EPERM;
> +
> +}
> +
> +static int my_get_framerate(struct i2c_client *client, u32 arg)
> +{
> +
> + return -EPERM;
> +
> +}
> +
> +static int my_set_window(struct i2c_client *client, u32 res)
> +{
> +
> + return 0;
> +}
> +
> +static int my_set_resolution(struct i2c_client *client, u32 res)
> +{
> +
> + switch (res) {
> +
> + default:
> + my_set_window(client, res);
> +
> + }
> +
> + return 0;
> +}
> +
> +static int my_init(struct i2c_client *client, u32 arg)
> +{
> + const char *b, *end;
> +
> + if (my_probe(client))
> + return -ENODEV;
> +
> + WriteWord(client, 0x12, 0x80); /* reset */
> +
> + msleep(100);
> +
> + b = myconfig;
> + end = &b[sizeof(myconfig)];
> +
> + while (b < end) {
> + WriteWord(client, b[0], b[1]);
> + b += 2;
> + }
> +
> + return 0;
> +
> +}
> +
> +static int my_exit(struct i2c_client *client, u32 arg)
> +{
> + return 0;
> +}
> +
> +int cam_control(struct i2c_client *client, u32 cmd, u32 arg)
> +{
> + switch (cmd) {
> + case CAM_CMD_INIT:
> + return my_init(client, arg);
> + case CAM_CMD_SET_RESOLUTION:
> + return my_set_resolution(client, arg);
> + case CAM_CMD_SET_FRAMERATE:
> + return my_set_framerate(client, arg);
> + case CAM_CMD_SET_PIXFMT:
> + return my_set_pixfmt(client, arg);
> + case CAM_CMD_EXIT:
> + return my_exit(client, arg);
> + default:
> + return -ENOIOCTLCMD;
> + }
> + return 0;
> +}
> +
> +/****************************************************************************
> + * sysfs
> + ***************************************************************************/
> +
> +static u8 sysfs_strtou8(const char *buff, size_t len, ssize_t *count)
> +{
> + char str[5];
> + char *endp;
> + unsigned long val;
> +
> + if (len < 4) {
> + strncpy(str, buff, len);
> + str[len + 1] = '\0';
> + } else {
> + strncpy(str, buff, 4);
> + str[4] = '\0';
> + }
> +
> + val = simple_strtoul(str, &endp, 0);
> +
> + *count = 0;
> + if (val <= 0xff)
> + *count = (ssize_t) (endp - str);
> + if ((*count) && (len == *count + 1) && (buff[*count] == '\n'))
> + *count += 1;
> +
> + return (u8) val;
> +}
> +
> +static ssize_t sysfs_sysfs_show_val(struct class_device *cd, char *buf, int
> cmd)
> +{
> + struct bcap_device_t *cam;
> + ssize_t count;
> + u8 val[1];
> +
> + if (mutex_lock_interruptible(&ov9655_sysfs_lock))
> + return -ERESTARTSYS;
> +
> + cam = video_get_drvdata(to_video_device(cd));
> + if (!cam) {
> + mutex_unlock(&ov9655_sysfs_lock);
> + return -ENODEV;
> + }
> +
> + if (cam_control(cam->client, cmd, (u32) val) < 0) {
> + mutex_unlock(&ov9655_sysfs_lock);
> + return -EIO;
> + }
> +
> + count = sprintf(buf, "%d\n", val[0]);
> +
> + mutex_unlock(&ov9655_sysfs_lock);
> +
> + return count;
> +}
> +
> +static ssize_t
> +sysfs_sysfs_store_val(struct class_device *cd, const char *buf, size_t len,
> + int cmd)
> +{
> + struct bcap_device_t *cam;
> + u8 value;
> + ssize_t count;
> + int err;
> +
> + if (mutex_lock_interruptible(&ov9655_sysfs_lock))
> + return -ERESTARTSYS;
> +
> + cam = video_get_drvdata(to_video_device(cd));
> +
> + if (!cam) {
> + mutex_unlock(&ov9655_sysfs_lock);
> + return -ENODEV;
> + }
> +
> + value = sysfs_strtou8(buf, len, &count);
> +
> + if (!count) {
> + mutex_unlock(&ov9655_sysfs_lock);
> + return -EINVAL;
> + }
> +
> + err = cam_control(cam->client, cmd, value);
> +
> + if (err) {
> + mutex_unlock(&ov9655_sysfs_lock);
> + return -EIO;
> + }
> +
> + mutex_unlock(&ov9655_sysfs_lock);
> +
> + return count;
> +}
> +
> +static ssize_t sysfs_fps_show(struct class_device *cd, char *buf)
> +{
> +
> + return sysfs_sysfs_show_val(cd, buf, CAM_CMD_GET_FRAMERATE);
> +}
> +
> +static ssize_t
> +sysfs_fps_store(struct class_device *cd, const char *buf, size_t len)
> +{
> + return sysfs_sysfs_store_val(cd, buf, len, CAM_CMD_SET_FRAMERATE);
> +}
> +
> +static CLASS_DEVICE_ATTR(fps, S_IRUGO | S_IWUSR,
> + sysfs_fps_show, sysfs_fps_store);
> +
> +static ssize_t sysfs_flicker_show(struct class_device *cd, char *buf)
> +{
> + return sysfs_sysfs_show_val(cd, buf, CAM_CMD_GET_FLICKER_FREQ);
> +}
> +
> +static ssize_t
> +sysfs_flicker_store(struct class_device *cd, const char *buf, size_t len)
> +{
> + return sysfs_sysfs_store_val(cd, buf, len, CAM_CMD_SET_FLICKER_FREQ);
> +}
> +
> +static CLASS_DEVICE_ATTR(flicker, S_IRUGO | S_IWUSR,
> + sysfs_flicker_show, sysfs_flicker_store);
> +
> +static ssize_t sysfs_h_mirror_show(struct class_device *cd, char *buf)
> +{
> + return sysfs_sysfs_show_val(cd, buf, CAM_CMD_GET_HOR_MIRROR);
> +}
> +
> +static ssize_t
> +sysfs_h_mirror_store(struct class_device *cd, const char *buf, size_t len)
> +{
> + return sysfs_sysfs_store_val(cd, buf, len, CAM_CMD_SET_HOR_MIRROR);
> +}
> +
> +static CLASS_DEVICE_ATTR(h_mirror, S_IRUGO | S_IWUSR,
> + sysfs_h_mirror_show, sysfs_h_mirror_store);
> +
> +static ssize_t sysfs_v_mirror_show(struct class_device *cd, char *buf)
> +{
> + return sysfs_sysfs_show_val(cd, buf, CAM_CMD_GET_VERT_MIRROR);
> +}
> +
> +static ssize_t
> +sysfs_v_mirror_store(struct class_device *cd, const char *buf, size_t len)
> +{
> + return sysfs_sysfs_store_val(cd, buf, len, CAM_CMD_SET_VERT_MIRROR);
> +}
> +
> +static CLASS_DEVICE_ATTR(v_mirror, S_IRUGO | S_IWUSR,
> + sysfs_v_mirror_show, sysfs_v_mirror_store);
> +
> +static int ov9655_create_sysfs(struct video_device *v4ldev)
> +{
> +
> + int rc;
> +
> + rc = video_device_create_file(v4ldev, &class_device_attr_fps);
> + if (rc)
> + goto err;
> + rc = video_device_create_file(v4ldev, &class_device_attr_flicker);
> + if (rc)
> + goto err_flicker;
> + rc = video_device_create_file(v4ldev, &class_device_attr_v_mirror);
> + if (rc)
> + goto err_v_mirror;
> + rc = video_device_create_file(v4ldev, &class_device_attr_h_mirror);
> + if (rc)
> + goto err_h_mirror;
> +
> + return 0;
> +
> +err_h_mirror:
> + video_device_remove_file(v4ldev, &class_device_attr_v_mirror);
> +err_v_mirror:
> + video_device_remove_file(v4ldev, &class_device_attr_flicker);
> +err_flicker:
> + video_device_remove_file(v4ldev, &class_device_attr_fps);
> +err:
> + return rc;
> +}
> +
> +static struct bcap_camera_ops ov9655_ops = {
> + cam_control,
> + ov9655_create_sysfs,
> + NULL,
> +};
> +
> +struct bcap_camera_ops *get_camops(void)
> +{
> + return (&ov9655_ops);
> +
> +}
> +EXPORT_SYMBOL(get_camops);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Michael Hennerich <[EMAIL PROTECTED]>");
> Added: trunk/drivers/media/video/blackfin/ov9655.h (0 => 4017)
>
> --- trunk/drivers/media/video/blackfin/ov9655.h
> (rev 0)
> +++ trunk/drivers/media/video/blackfin/ov9655.h 2007-12-10 16:24:25 UTC
> (rev 4017)
> @@ -0,0 +1,75 @@
> +/*
> + * File: drivers/media/video/blackfin/mt9v022.h
> + * Based on:
> + * Author: Michael Hennerich <[EMAIL PROTECTED]>
> + *
> + * Created:
> + * Description: Command driver for Micron MT9V022 sensor
> + *
> + *
> + * Modified:
> + * Copyright 2004-2007 Analog Devices Inc.
> + *
> + * Bugs: Enter bugs at http://blackfin.uclinux.org/
> + *
> + * 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, see the file COPYING, or write
> + * to the Free Software Foundation, Inc.,
> + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef OV9655_H
> +#define OV9655_H
> +
> +#include "blackfin_cam.h"
> +
> +/*0 = VIDEO_PALETTE_GREY
> + 1 = VIDEO_PALETTE_RGB565
> + 2 = VIDEO_PALETTE_YUV422
> + 3 = VIDEO_PALETTE_UYVY */
> +
> +#define DEFAULT_FORMAT 3
> +
> +# define POL_C 0x0000
> +# define POL_S 0x0000
> +# define PIXEL_PER_LINE 1280
> +# define LINES_PER_FRAME 1024
> +# define CFG_GP_Input_3Syncs 0x0020
> +# define GP_Input_Mode 0x000C
> +# define PPI_DATA_LEN DLEN_8
> +# define PPI_PACKING PACK_EN
> +# define DMA_FLOW_MODE 0x0000 /* STOPMODE */
> +# define DMA_WDSIZE_16 WDSIZE_16
> +
> +
> +#define I2C_SENSOR_ID (0x30 << 1)
> +#define MAX_FRAME_WIDTH 1280
> +#define MAX_FRAME_HEIGHT 1024
> +#define MIN_FRAME_WIDTH 80
> +#define MIN_FRAME_HEIGHT 60
> +#define DEFAULT_DEPTH 16
> +#define CORR_VAL 0
> +
> +#define ROW_OFF_MIN 4
> +#define COL_OFF_MIN 1
> +
> +#define USE_2ND_BUF_IN_CACHED_MEM
> +
> +#define SENSOR_NAME "OV9655"
> +
> +struct bcap_camera_ops *get_camops(void);
> +
> +#define MAX_FRAMERATE 30
> +
> +
> +#endif /* OV9655_H */
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
http://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits