linux/drivers/media/video/zc0301/zc0301_pb0330.c
<<
>>
Prefs
   1/***************************************************************************
   2 * Plug-in for PB-0330 image sensor connected to the ZC0301P Image         *
   3 * Processor and Control Chip                                              *
   4 *                                                                         *
   5 * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it>  *
   6 *                                                                         *
   7 * Initialization values of the ZC0301[P] have been taken from the SPCA5XX *
   8 * driver maintained by Michel Xhaard <mxhaard@magic.fr>                   *
   9 *                                                                         *
  10 * This program is free software; you can redistribute it and/or modify    *
  11 * it under the terms of the GNU General Public License as published by    *
  12 * the Free Software Foundation; either version 2 of the License, or       *
  13 * (at your option) any later version.                                     *
  14 *                                                                         *
  15 * This program is distributed in the hope that it will be useful,         *
  16 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
  17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
  18 * GNU General Public License for more details.                            *
  19 *                                                                         *
  20 * You should have received a copy of the GNU General Public License       *
  21 * along with this program; if not, write to the Free Software             *
  22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               *
  23 ***************************************************************************/
  24
  25#include <linux/delay.h>
  26#include "zc0301_sensor.h"
  27
  28
  29static struct zc0301_sensor pb0330;
  30
  31
  32static int pb0330_init(struct zc0301_device* cam)
  33{
  34        int err = 0;
  35
  36        err += zc0301_write_reg(cam, 0x0000, 0x01);
  37        err += zc0301_write_reg(cam, 0x0008, 0x03);
  38        err += zc0301_write_reg(cam, 0x0010, 0x0A);
  39        err += zc0301_write_reg(cam, 0x0002, 0x00);
  40        err += zc0301_write_reg(cam, 0x0003, 0x02);
  41        err += zc0301_write_reg(cam, 0x0004, 0x80);
  42        err += zc0301_write_reg(cam, 0x0005, 0x01);
  43        err += zc0301_write_reg(cam, 0x0006, 0xE0);
  44        err += zc0301_write_reg(cam, 0x0001, 0x01);
  45        err += zc0301_write_reg(cam, 0x0012, 0x05);
  46        err += zc0301_write_reg(cam, 0x0012, 0x07);
  47        err += zc0301_write_reg(cam, 0x0098, 0x00);
  48        err += zc0301_write_reg(cam, 0x009A, 0x00);
  49        err += zc0301_write_reg(cam, 0x011A, 0x00);
  50        err += zc0301_write_reg(cam, 0x011C, 0x00);
  51        err += zc0301_write_reg(cam, 0x0012, 0x05);
  52
  53        err += zc0301_i2c_write(cam, 0x01, 0x0006);
  54        err += zc0301_i2c_write(cam, 0x02, 0x0011);
  55        err += zc0301_i2c_write(cam, 0x03, 0x01E7);
  56        err += zc0301_i2c_write(cam, 0x04, 0x0287);
  57        err += zc0301_i2c_write(cam, 0x06, 0x0003);
  58        err += zc0301_i2c_write(cam, 0x07, 0x3002);
  59        err += zc0301_i2c_write(cam, 0x20, 0x1100);
  60        err += zc0301_i2c_write(cam, 0x2F, 0xF7B0);
  61        err += zc0301_i2c_write(cam, 0x30, 0x0005);
  62        err += zc0301_i2c_write(cam, 0x31, 0x0000);
  63        err += zc0301_i2c_write(cam, 0x34, 0x0100);
  64        err += zc0301_i2c_write(cam, 0x35, 0x0060);
  65        err += zc0301_i2c_write(cam, 0x3D, 0x068F);
  66        err += zc0301_i2c_write(cam, 0x40, 0x01E0);
  67        err += zc0301_i2c_write(cam, 0x58, 0x0078);
  68        err += zc0301_i2c_write(cam, 0x62, 0x0411);
  69
  70        err += zc0301_write_reg(cam, 0x0087, 0x10);
  71        err += zc0301_write_reg(cam, 0x0101, 0x37);
  72        err += zc0301_write_reg(cam, 0x0012, 0x05);
  73        err += zc0301_write_reg(cam, 0x0100, 0x0D);
  74        err += zc0301_write_reg(cam, 0x0189, 0x06);
  75        err += zc0301_write_reg(cam, 0x01AD, 0x00);
  76        err += zc0301_write_reg(cam, 0x01C5, 0x03);
  77        err += zc0301_write_reg(cam, 0x01CB, 0x13);
  78        err += zc0301_write_reg(cam, 0x0250, 0x08);
  79        err += zc0301_write_reg(cam, 0x0301, 0x08);
  80        err += zc0301_write_reg(cam, 0x01A8, 0x60);
  81        err += zc0301_write_reg(cam, 0x018D, 0x6C);
  82        err += zc0301_write_reg(cam, 0x01AD, 0x09);
  83        err += zc0301_write_reg(cam, 0x01AE, 0x15);
  84        err += zc0301_write_reg(cam, 0x010A, 0x50);
  85        err += zc0301_write_reg(cam, 0x010B, 0xF8);
  86        err += zc0301_write_reg(cam, 0x010C, 0xF8);
  87        err += zc0301_write_reg(cam, 0x010D, 0xF8);
  88        err += zc0301_write_reg(cam, 0x010E, 0x50);
  89        err += zc0301_write_reg(cam, 0x010F, 0xF8);
  90        err += zc0301_write_reg(cam, 0x0110, 0xF8);
  91        err += zc0301_write_reg(cam, 0x0111, 0xF8);
  92        err += zc0301_write_reg(cam, 0x0112, 0x50);
  93        err += zc0301_write_reg(cam, 0x0008, 0x03);
  94        err += zc0301_write_reg(cam, 0x01C6, 0x08);
  95        err += zc0301_write_reg(cam, 0x01CB, 0x0F);
  96        err += zc0301_write_reg(cam, 0x010A, 0x50);
  97        err += zc0301_write_reg(cam, 0x010B, 0xF8);
  98        err += zc0301_write_reg(cam, 0x010C, 0xF8);
  99        err += zc0301_write_reg(cam, 0x010D, 0xF8);
 100        err += zc0301_write_reg(cam, 0x010E, 0x50);
 101        err += zc0301_write_reg(cam, 0x010F, 0xF8);
 102        err += zc0301_write_reg(cam, 0x0110, 0xF8);
 103        err += zc0301_write_reg(cam, 0x0111, 0xF8);
 104        err += zc0301_write_reg(cam, 0x0112, 0x50);
 105        err += zc0301_write_reg(cam, 0x0180, 0x00);
 106        err += zc0301_write_reg(cam, 0x0019, 0x00);
 107
 108        err += zc0301_i2c_write(cam, 0x05, 0x0066);
 109        err += zc0301_i2c_write(cam, 0x09, 0x02B2);
 110        err += zc0301_i2c_write(cam, 0x10, 0x0002);
 111
 112        err += zc0301_write_reg(cam, 0x011D, 0x60);
 113        err += zc0301_write_reg(cam, 0x0190, 0x00);
 114        err += zc0301_write_reg(cam, 0x0191, 0x07);
 115        err += zc0301_write_reg(cam, 0x0192, 0x8C);
 116        err += zc0301_write_reg(cam, 0x0195, 0x00);
 117        err += zc0301_write_reg(cam, 0x0196, 0x00);
 118        err += zc0301_write_reg(cam, 0x0197, 0x8A);
 119        err += zc0301_write_reg(cam, 0x018C, 0x10);
 120        err += zc0301_write_reg(cam, 0x018F, 0x20);
 121        err += zc0301_write_reg(cam, 0x01A9, 0x14);
 122        err += zc0301_write_reg(cam, 0x01AA, 0x24);
 123        err += zc0301_write_reg(cam, 0x001D, 0xD7);
 124        err += zc0301_write_reg(cam, 0x001E, 0xF0);
 125        err += zc0301_write_reg(cam, 0x001F, 0xF8);
 126        err += zc0301_write_reg(cam, 0x0020, 0xFF);
 127        err += zc0301_write_reg(cam, 0x01AD, 0x09);
 128        err += zc0301_write_reg(cam, 0x01AE, 0x15);
 129        err += zc0301_write_reg(cam, 0x0180, 0x40);
 130        err += zc0301_write_reg(cam, 0x0180, 0x42);
 131
 132        msleep(100);
 133
 134        return err;
 135}
 136
 137
 138static struct zc0301_sensor pb0330 = {
 139        .name = "PB-0330",
 140        .init = &pb0330_init,
 141        .cropcap = {
 142                .bounds = {
 143                        .left = 0,
 144                        .top = 0,
 145                        .width = 640,
 146                        .height = 480,
 147                },
 148                .defrect = {
 149                        .left = 0,
 150                        .top = 0,
 151                        .width = 640,
 152                        .height = 480,
 153                },
 154        },
 155        .pix_format = {
 156                .width = 640,
 157                .height = 480,
 158                .pixelformat = V4L2_PIX_FMT_JPEG,
 159                .priv = 8,
 160                .colorspace = V4L2_COLORSPACE_JPEG,
 161        },
 162};
 163
 164
 165int zc0301_probe_pb0330(struct zc0301_device* cam)
 166{
 167        int r0, err = 0;
 168
 169        err += zc0301_write_reg(cam, 0x0000, 0x01);
 170        err += zc0301_write_reg(cam, 0x0010, 0x0a);
 171        err += zc0301_write_reg(cam, 0x0001, 0x01);
 172        err += zc0301_write_reg(cam, 0x0012, 0x03);
 173        err += zc0301_write_reg(cam, 0x0012, 0x01);
 174
 175        msleep(10);
 176
 177        r0 = zc0301_i2c_read(cam, 0x00, 2);
 178
 179        if (r0 < 0 || err)
 180                return -EIO;
 181
 182        if (r0 != 0x8243)
 183                return -ENODEV;
 184
 185        zc0301_attach_sensor(cam, &pb0330);
 186
 187        return 0;
 188}
 189