Fix SXGA support to enforce bayer format
[microdia.git] / hv7131r.c
blob4ae7c2a19721f6410aa0676e76834592b10556ee
1 /**
2 * @file hv7131r.c
3 * @author Josua Grawitter
4 * @date 2008-12-17
6 * @brief Common control functions the HV7131R Image Sensor
8 * @note Copyright (C) Josua Grawitter
10 * @par Licences
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "sn9c20x.h"
28 #include "sn9c20x-bridge.h"
30 struct sn9c20x_i2c_regs hv7131r_init[] = {
31 {0x02, 0x08},
32 {0x02, 0x00},
33 {0x01, 0x08},
34 {0x02, 0x00},
35 {0x20, 0x00},
36 {0x21, 0xd0},
37 {0x22, 0x00},
38 {0x23, 0x09},
39 {0x01, 0x08},
40 {0x01, 0x08},
41 {0x01, 0x08},
42 {0x25, 0x07},
43 {0x26, 0xc3},
44 {0x27, 0x50},
45 {0x30, 0x62},
46 {0x31, 0x10},
47 {0x32, 0x06},
48 {0x33, 0x10},
49 {0x20, 0x00},
50 {0x21, 0xd0},
51 {0x22, 0x00},
52 {0x23, 0x09},
53 {0x01, 0x08},
54 {0xff, 0xff},
58 int hv7131r_set_exposure(struct usb_sn9c20x *dev)
60 __u8 buf[3];
61 int ret;
62 __u32 val;
64 val = ((dev->vsettings.exposure << 8) * 0xffffff) / 0xffff;
66 buf[0] = (val >> 16) & 0xff;
67 buf[1] = (val >> 8) & 0xff;
68 buf[2] = val & 0xff;
70 ret = sn9c20x_write_i2c_data_ext(dev, 3, 0x25, buf, 0x1e);
72 return ret;
75 int hv7131r_set_gain(struct usb_sn9c20x *dev)
77 __u8 buf;
78 int ret;
80 buf = dev->vsettings.gain;
82 ret = sn9c20x_write_i2c_data_ext(dev, 1, 0x30, &buf, 0x1d);
84 return ret;
87 int hv7131r_set_hvflip(struct usb_sn9c20x *dev)
89 __u8 buf;
90 int ret;
92 ret = sn9c20x_read_i2c_data(dev, 1, 0x01, &buf);
93 if (ret < 0)
94 return ret;
96 if (dev->vsettings.hflip)
97 buf |= 0x02;
98 else
99 buf &= ~0x02;
101 if (dev->vsettings.vflip)
102 buf |= 0x01;
103 else
104 buf &= ~0x01;
106 ret = sn9c20x_write_i2c_data(dev, 1, 0x01, &buf);
108 return ret;