31 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
95 static int hdcs_reg_write_seq(
struct sd *
sd,
u8 reg,
u8 *vals,
u8 len)
104 for (i = 0; i < len; i++) {
106 regs[2 * i + 1] = vals[
i];
121 if (hdcs->
state == state)
158 static int hdcs_reset(
struct sd *sd)
176 struct sd *sd = (
struct sd *) gspca_dev;
195 cp = hdcs->
exp.cto + (hdcs->
w * ct / 2);
198 rp = hdcs->
exp.rs +
cp;
200 rowexp = cycles /
rp;
203 cycles -= rowexp *
rp;
208 srowexp = hdcs->
w - (cycles + hdcs->
exp.er + 13) / ct;
210 mnct = (hdcs->
exp.er + 12 + ct - 1) / ct;
211 max_srowexp = hdcs->
w - mnct;
214 srowexp = cp - hdcs->
exp.er - 6 - cycles;
216 mnct = (hdcs->
exp.er + 5 + ct - 1) / ct;
217 max_srowexp = cp - mnct * ct - 1;
222 else if (srowexp > max_srowexp)
223 srowexp = max_srowexp;
229 exp[3] = rowexp & 0xff;
231 exp[5] = rowexp >> 8;
233 exp[7] = (srowexp >> 2) & 0xff;
243 exp[3] = rowexp & 0xff;
245 exp[5] = rowexp >> 8;
247 exp[7] = srowexp & 0xff;
249 exp[9] = srowexp >> 8;
258 PDEBUG(D_V4L2,
"Writing exposure %d, rowexp %d, srowexp %d",
259 val, rowexp, srowexp);
263 static int hdcs_set_gains(
struct sd *sd,
u8 g)
281 static int hdcs_set_gain(
struct gspca_dev *gspca_dev,
__s32 val)
283 PDEBUG(D_V4L2,
"Writing gain %d", val);
284 return hdcs_set_gains((
struct sd *) gspca_dev,
288 static int hdcs_set_size(
struct sd *sd,
297 width = (width + 3) & ~0x3;
298 height = (height + 3) & ~0x3;
300 if (width > hdcs->
array.width)
301 width = hdcs->
array.width;
306 > hdcs->
array.height)
307 height = hdcs->
array.height - 2 * hdcs->
array.border -
313 if (height > hdcs->
array.height)
314 height = hdcs->
array.height;
323 win[2] = (y +
height) / 4 - 1;
324 win[3] = (x +
width) / 4 - 1;
326 err = hdcs_reg_write_seq(sd,
HDCS_FWROW, win, 4);
338 struct gspca_dev *gspca_dev =
344 err = hdcs_set_gain(gspca_dev, ctrl->
val);
347 err = hdcs_set_exposure(gspca_dev, ctrl->
val);
354 .s_ctrl = hdcs_s_ctrl,
357 static int hdcs_init_controls(
struct sd *sd)
369 static int hdcs_probe_1x00(
struct sd *sd)
376 if (ret < 0 || sensor != 0x08)
379 pr_info(
"HDCS-1000/1100 sensor detected\n");
381 sd->
gspca_dev.cam.cam_mode = hdcs1x00_mode;
388 hdcs->
array.left = 8;
392 hdcs->
array.border = 4;
426 static int hdcs_probe_1020(
struct sd *sd)
433 if (ret < 0 || sensor != 0x10)
436 pr_info(
"HDCS-1020 sensor detected\n");
438 sd->
gspca_dev.cam.cam_mode = hdcs1020_mode;
450 hdcs->
array.left = 24;
453 hdcs->
array.height = 304;
454 hdcs->
array.border = 4;
468 static int hdcs_start(
struct sd *sd)
470 PDEBUG(D_STREAM,
"Starting stream");
475 static int hdcs_stop(
struct sd *sd)
477 PDEBUG(D_STREAM,
"Halting stream");
482 static int hdcs_init(
struct sd *sd)
494 stv_bridge_init[i][1]);
505 stv_sensor_init[i][1]);
526 return hdcs_set_size(sd, hdcs->
array.width, hdcs->
array.height);
529 static int hdcs_dump(
struct sd *sd)
533 pr_info(
"Dumping sensor registers:\n");
537 pr_info(
"reg 0x%02x = 0x%02x\n", reg, val);