Lines Matching +full:y +full:- +full:rp

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
4 * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
7 * Copyright (c) 2008 Chia-I Wu
10 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
11 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
12 * P/N 861055: Sensor ST VV6410 ASIC STV0610 - LEGO cam
13 * P/N 861075-0040: Sensor HDCS1000 ASIC
14 * P/N 961179-0700: Sensor ST VV6410 ASIC STV0602 - Dexxa WebCam USB
15 * P/N 861040-0000: Sensor ST VV6410 ASIC STV0610 - QuickCam Web
89 return -EINVAL; in hdcs_reg_write_seq()
104 struct hdcs *hdcs = sd->sensor_priv; in hdcs_set_state()
108 if (hdcs->state == state) in hdcs_set_state()
112 if (hdcs->state != HDCS_STATE_IDLE) { in hdcs_set_state()
118 hdcs->state = HDCS_STATE_IDLE; in hdcs_set_state()
133 return -EINVAL; in hdcs_set_state()
140 hdcs->state = state; in hdcs_set_state()
147 struct hdcs *hdcs = sd->sensor_priv; in hdcs_reset()
156 hdcs->state = HDCS_STATE_IDLE; in hdcs_reset()
164 struct hdcs *hdcs = sd->sensor_priv; in hdcs_set_exposure()
172 int rp; in hdcs_set_exposure() local
181 ct = hdcs->exp.cto + hdcs->psmp + (HDCS_ADC_START_SIG_DUR + 2); in hdcs_set_exposure()
182 cp = hdcs->exp.cto + (hdcs->w * ct / 2); in hdcs_set_exposure()
185 rp = hdcs->exp.rs + cp; in hdcs_set_exposure()
187 rowexp = cycles / rp; in hdcs_set_exposure()
190 cycles -= rowexp * rp; in hdcs_set_exposure()
192 /* calculate sub-row exposure */ in hdcs_set_exposure()
194 /* see HDCS-1020 datasheet 3.5.6.4, p. 63 */ in hdcs_set_exposure()
195 srowexp = hdcs->w - (cycles + hdcs->exp.er + 13) / ct; in hdcs_set_exposure()
197 mnct = (hdcs->exp.er + 12 + ct - 1) / ct; in hdcs_set_exposure()
198 max_srowexp = hdcs->w - mnct; in hdcs_set_exposure()
200 /* see HDCS-1000 datasheet 3.4.5.5, p. 61 */ in hdcs_set_exposure()
201 srowexp = cp - hdcs->exp.er - 6 - cycles; in hdcs_set_exposure()
203 mnct = (hdcs->exp.er + 5 + ct - 1) / ct; in hdcs_set_exposure()
204 max_srowexp = cp - mnct * ct - 1; in hdcs_set_exposure()
278 struct hdcs *hdcs = sd->sensor_priv; in hdcs_set_size()
280 unsigned int x, y; in hdcs_set_size() local
287 if (width > hdcs->array.width) in hdcs_set_size()
288 width = hdcs->array.width; in hdcs_set_size()
292 if (height + 2 * hdcs->array.border + HDCS_1020_BOTTOM_Y_SKIP in hdcs_set_size()
293 > hdcs->array.height) in hdcs_set_size()
294 height = hdcs->array.height - 2 * hdcs->array.border - in hdcs_set_size()
297 y = (hdcs->array.height - HDCS_1020_BOTTOM_Y_SKIP - height) / 2 in hdcs_set_size()
298 + hdcs->array.top; in hdcs_set_size()
300 if (height > hdcs->array.height) in hdcs_set_size()
301 height = hdcs->array.height; in hdcs_set_size()
303 y = hdcs->array.top + (hdcs->array.height - height) / 2; in hdcs_set_size()
306 x = hdcs->array.left + (hdcs->array.width - width) / 2; in hdcs_set_size()
308 win[0] = y / 4; in hdcs_set_size()
310 win[2] = (y + height) / 4 - 1; in hdcs_set_size()
311 win[3] = (x + width) / 4 - 1; in hdcs_set_size()
318 hdcs->w = width; in hdcs_set_size()
319 hdcs->h = height; in hdcs_set_size()
326 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in hdcs_s_ctrl()
327 int err = -EINVAL; in hdcs_s_ctrl()
329 switch (ctrl->id) { in hdcs_s_ctrl()
331 err = hdcs_set_gain(gspca_dev, ctrl->val); in hdcs_s_ctrl()
334 err = hdcs_set_exposure(gspca_dev, ctrl->val); in hdcs_s_ctrl()
346 struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler; in hdcs_init_controls()
353 return hdl->error; in hdcs_init_controls()
364 return -ENODEV; in hdcs_probe_1x00()
366 pr_info("HDCS-1000/1100 sensor detected\n"); in hdcs_probe_1x00()
368 sd->gspca_dev.cam.cam_mode = hdcs1x00_mode; in hdcs_probe_1x00()
369 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(hdcs1x00_mode); in hdcs_probe_1x00()
373 return -ENOMEM; in hdcs_probe_1x00()
375 hdcs->array.left = 8; in hdcs_probe_1x00()
376 hdcs->array.top = 8; in hdcs_probe_1x00()
377 hdcs->array.width = HDCS_1X00_DEF_WIDTH; in hdcs_probe_1x00()
378 hdcs->array.height = HDCS_1X00_DEF_HEIGHT; in hdcs_probe_1x00()
379 hdcs->array.border = 4; in hdcs_probe_1x00()
381 hdcs->exp.cto = 4; in hdcs_probe_1x00()
382 hdcs->exp.cpo = 2; in hdcs_probe_1x00()
383 hdcs->exp.rs = 186; in hdcs_probe_1x00()
384 hdcs->exp.er = 100; in hdcs_probe_1x00()
387 * Frame rate on HDCS-1000 with STV600 depends on PSMP: in hdcs_probe_1x00()
396 * Frame rate on HDCS-1000 with STV602 depends on PSMP: in hdcs_probe_1x00()
406 hdcs->psmp = (sd->bridge == BRIDGE_STV602) ? 20 : 5; in hdcs_probe_1x00()
408 sd->sensor_priv = hdcs; in hdcs_probe_1x00()
421 return -ENODEV; in hdcs_probe_1020()
423 pr_info("HDCS-1020 sensor detected\n"); in hdcs_probe_1020()
425 sd->gspca_dev.cam.cam_mode = hdcs1020_mode; in hdcs_probe_1020()
426 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(hdcs1020_mode); in hdcs_probe_1020()
430 return -ENOMEM; in hdcs_probe_1020()
433 * From Andrey's test image: looks like HDCS-1020 upper-left in hdcs_probe_1020()
434 * visible pixel is at 24,8 (y maybe even smaller?) and lower-right in hdcs_probe_1020()
437 hdcs->array.left = 24; in hdcs_probe_1020()
438 hdcs->array.top = 4; in hdcs_probe_1020()
439 hdcs->array.width = HDCS_1020_DEF_WIDTH; in hdcs_probe_1020()
440 hdcs->array.height = 304; in hdcs_probe_1020()
441 hdcs->array.border = 4; in hdcs_probe_1020()
443 hdcs->psmp = 6; in hdcs_probe_1020()
445 hdcs->exp.cto = 3; in hdcs_probe_1020()
446 hdcs->exp.cpo = 3; in hdcs_probe_1020()
447 hdcs->exp.rs = 155; in hdcs_probe_1020()
448 hdcs->exp.er = 96; in hdcs_probe_1020()
450 sd->sensor_priv = hdcs; in hdcs_probe_1020()
475 struct hdcs *hdcs = sd->sensor_priv; in hdcs_init()
479 if (sd->bridge == BRIDGE_STV602) in hdcs_init()
507 (was 0x7E for the STV602, but caused slow framerate with HDCS-1020) */ in hdcs_init()
510 (HDCS_ADC_START_SIG_DUR << 6) | hdcs->psmp); in hdcs_init()
513 (HDCS_ADC_START_SIG_DUR << 5) | hdcs->psmp); in hdcs_init()
517 return hdcs_set_size(sd, hdcs->array.width, hdcs->array.height); in hdcs_init()