aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/bt832.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/bt832.c')
-rw-r--r--drivers/media/video/bt832.c89
1 files changed, 44 insertions, 45 deletions
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index 76c1b63ebdf2..e4063950ae57 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -32,7 +32,6 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33 33
34#include <media/audiochip.h> 34#include <media/audiochip.h>
35#include <media/id.h>
36#include "bttv.h" 35#include "bttv.h"
37#include "bt832.h" 36#include "bt832.h"
38 37
@@ -54,36 +53,36 @@ static struct i2c_driver driver;
54static struct i2c_client client_template; 53static struct i2c_client client_template;
55 54
56struct bt832 { 55struct bt832 {
57 struct i2c_client client; 56 struct i2c_client client;
58}; 57};
59 58
60int bt832_hexdump(struct i2c_client *i2c_client_s, unsigned char *buf) 59int bt832_hexdump(struct i2c_client *i2c_client_s, unsigned char *buf)
61{ 60{
62 int i,rc; 61 int i,rc;
63 buf[0]=0x80; // start at register 0 with auto-increment 62 buf[0]=0x80; // start at register 0 with auto-increment
64 if (1 != (rc = i2c_master_send(i2c_client_s,buf,1))) 63 if (1 != (rc = i2c_master_send(i2c_client_s,buf,1)))
65 printk("bt832: i2c i/o error: rc == %d (should be 1)\n",rc); 64 printk("bt832: i2c i/o error: rc == %d (should be 1)\n",rc);
66 65
67 for(i=0;i<65;i++) 66 for(i=0;i<65;i++)
68 buf[i]=0; 67 buf[i]=0;
69 if (65 != (rc=i2c_master_recv(i2c_client_s,buf,65))) 68 if (65 != (rc=i2c_master_recv(i2c_client_s,buf,65)))
70 printk("bt832: i2c i/o error: rc == %d (should be 65)\n",rc); 69 printk("bt832: i2c i/o error: rc == %d (should be 65)\n",rc);
71 70
72 // Note: On READ the first byte is the current index 71 // Note: On READ the first byte is the current index
73 // (e.g. 0x80, what we just wrote) 72 // (e.g. 0x80, what we just wrote)
74 73
75 if(1) { 74 if(1) {
76 int i; 75 int i;
77 printk("BT832 hexdump:\n"); 76 printk("BT832 hexdump:\n");
78 for(i=1;i<65;i++) { 77 for(i=1;i<65;i++) {
79 if(i!=1) { 78 if(i!=1) {
80 if(((i-1)%8)==0) printk(" "); 79 if(((i-1)%8)==0) printk(" ");
81 if(((i-1)%16)==0) printk("\n"); 80 if(((i-1)%16)==0) printk("\n");
82 } 81 }
83 printk(" %02x",buf[i]); 82 printk(" %02x",buf[i]);
84 } 83 }
85 printk("\n"); 84 printk("\n");
86 } 85 }
87 return 0; 86 return 0;
88} 87}
89 88
@@ -102,13 +101,13 @@ int bt832_init(struct i2c_client *i2c_client_s)
102 return 0; 101 return 0;
103 } 102 }
104 103
105 printk("Write 0 tp VPSTATUS\n"); 104 printk("Write 0 tp VPSTATUS\n");
106 buf[0]=BT832_VP_STATUS; // Reg.52 105 buf[0]=BT832_VP_STATUS; // Reg.52
107 buf[1]= 0x00; 106 buf[1]= 0x00;
108 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 107 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
109 printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc); 108 printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc);
110 109
111 bt832_hexdump(i2c_client_s,buf); 110 bt832_hexdump(i2c_client_s,buf);
112 111
113 112
114 // Leave low power mode: 113 // Leave low power mode:
@@ -116,17 +115,17 @@ int bt832_init(struct i2c_client *i2c_client_s)
116 buf[0]=BT832_CAM_SETUP0; //0x39 57 115 buf[0]=BT832_CAM_SETUP0; //0x39 57
117 buf[1]=0x08; 116 buf[1]=0x08;
118 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 117 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
119 printk("bt832: i2c i/o error LLPM: rc == %d (should be 2)\n",rc); 118 printk("bt832: i2c i/o error LLPM: rc == %d (should be 2)\n",rc);
120 119
121 bt832_hexdump(i2c_client_s,buf); 120 bt832_hexdump(i2c_client_s,buf);
122 121
123 printk("Write 0 tp VPSTATUS\n"); 122 printk("Write 0 tp VPSTATUS\n");
124 buf[0]=BT832_VP_STATUS; // Reg.52 123 buf[0]=BT832_VP_STATUS; // Reg.52
125 buf[1]= 0x00; 124 buf[1]= 0x00;
126 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 125 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
127 printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc); 126 printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc);
128 127
129 bt832_hexdump(i2c_client_s,buf); 128 bt832_hexdump(i2c_client_s,buf);
130 129
131 130
132 // Enable Output 131 // Enable Output
@@ -134,22 +133,22 @@ int bt832_init(struct i2c_client *i2c_client_s)
134 buf[0]=BT832_VP_CONTROL1; // Reg.40 133 buf[0]=BT832_VP_CONTROL1; // Reg.40
135 buf[1]= 0x27 & (~0x01); // Default | !skip 134 buf[1]= 0x27 & (~0x01); // Default | !skip
136 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 135 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
137 printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc); 136 printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc);
138 137
139 bt832_hexdump(i2c_client_s,buf); 138 bt832_hexdump(i2c_client_s,buf);
140 139
141 140
142 // for testing (even works when no camera attached) 141 // for testing (even works when no camera attached)
143 printk("bt832: *** Generate NTSC M Bars *****\n"); 142 printk("bt832: *** Generate NTSC M Bars *****\n");
144 buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42 143 buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42
145 buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally 144 buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally
146 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 145 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
147 printk("bt832: i2c i/o error MBAR: rc == %d (should be 2)\n",rc); 146 printk("bt832: i2c i/o error MBAR: rc == %d (should be 2)\n",rc);
148 147
149 printk("Bt832: Camera Present: %s\n", 148 printk("Bt832: Camera Present: %s\n",
150 (buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no"); 149 (buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no");
151 150
152 bt832_hexdump(i2c_client_s,buf); 151 bt832_hexdump(i2c_client_s,buf);
153 kfree(buf); 152 kfree(buf);
154 return 1; 153 return 1;
155} 154}
@@ -162,17 +161,17 @@ static int bt832_attach(struct i2c_adapter *adap, int addr, int kind)
162 161
163 printk("bt832_attach\n"); 162 printk("bt832_attach\n");
164 163
165 client_template.adapter = adap; 164 client_template.adapter = adap;
166 client_template.addr = addr; 165 client_template.addr = addr;
167 166
168 printk("bt832: chip found @ 0x%x\n", addr<<1); 167 printk("bt832: chip found @ 0x%x\n", addr<<1);
169 168
170 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL))) 169 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL)))
171 return -ENOMEM; 170 return -ENOMEM;
172 memset(t,0,sizeof(*t)); 171 memset(t,0,sizeof(*t));
173 t->client = client_template; 172 t->client = client_template;
174 i2c_set_clientdata(&t->client, t); 173 i2c_set_clientdata(&t->client, t);
175 i2c_attach_client(&t->client); 174 i2c_attach_client(&t->client);
176 175
177 if(! bt832_init(&t->client)) { 176 if(! bt832_init(&t->client)) {
178 bt832_detach(&t->client); 177 bt832_detach(&t->client);
@@ -211,7 +210,7 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
211 210
212 printk("bt832: command %x\n",cmd); 211 printk("bt832: command %x\n",cmd);
213 212
214 switch (cmd) { 213 switch (cmd) {
215 case BT832_HEXDUMP: { 214 case BT832_HEXDUMP: {
216 unsigned char *buf; 215 unsigned char *buf;
217 buf=kmalloc(65,GFP_KERNEL); 216 buf=kmalloc(65,GFP_KERNEL);