19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
47 .ident =
"Fujitsu-Siemens Amilo Xa 2528",
53 .ident =
"Fujitsu-Siemens Amilo Xi 2428",
59 .ident =
"Fujitsu-Siemens Amilo Xi 2528",
65 .ident =
"Fujitsu-Siemens Amilo Xi 2550",
71 .ident =
"Fujitsu-Siemens Amilo Pa 2548",
98 .ident =
"MSI GX700/GX705/EX700",
110 .ident =
"Lenovo Y300",
138 .bytesperline = 1280,
144 static const struct ctrl s5k4aa_ctrls[] = {
150 .name =
"vertical flip",
156 .set = s5k4aa_set_vflip,
157 .get = s5k4aa_get_vflip
164 .name =
"horizontal flip",
170 .set = s5k4aa_set_hflip,
171 .get = s5k4aa_get_hflip
185 .set = s5k4aa_set_gain,
186 .get = s5k4aa_get_gain
188 #define EXPOSURE_IDX 3
197 .default_value = 0x100,
200 .set = s5k4aa_set_exposure,
201 .get = s5k4aa_get_exposure
203 #define NOISE_SUPP_IDX 4
208 .name =
"Noise suppression (smoothing)",
214 .set = s5k4aa_set_noise,
215 .get = s5k4aa_get_noise
217 #define BRIGHTNESS_IDX 5
222 .name =
"Brightness",
228 .set = s5k4aa_set_brightness,
229 .get = s5k4aa_get_brightness
234 static void s5k4aa_dump_registers(
struct sd *
sd);
238 u8 prod_id[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
239 const u8 expected_prod_id[6] = {0x00, 0x10, 0x00, 0x4b, 0x33, 0x75};
241 s32 *sensor_settings;
245 pr_info(
"Forcing a %s sensor\n", s5k4aa.name);
253 PDEBUG(D_PROBE,
"Probing for a s5k4aa sensor");
257 u8 data[2] = {0x00, 0x00};
259 switch (preinit_s5k4aa[i][0]) {
262 preinit_s5k4aa[i][1],
263 preinit_s5k4aa[i][2]);
267 data[0] = preinit_s5k4aa[
i][2];
269 preinit_s5k4aa[i][1],
274 data[0] = preinit_s5k4aa[
i][2];
275 data[1] = preinit_s5k4aa[
i][3];
277 preinit_s5k4aa[i][1],
281 pr_info(
"Invalid stream command, exiting init\n");
294 if (
memcmp(prod_id, expected_prod_id,
sizeof(prod_id)))
297 pr_info(
"Detected a s5k4aa sensor\n");
302 if (!sensor_settings)
305 sd->
gspca_dev.cam.cam_mode = s5k4aa_modes;
307 sd->
desc->ctrls = s5k4aa_ctrls;
310 for (i = 0; i <
ARRAY_SIZE(s5k4aa_ctrls); i++)
311 sensor_settings[i] = s5k4aa_ctrls[i].
qctrl.default_value;
326 PDEBUG(D_V4L2,
"Configuring camera for SXGA mode");
328 for (i = 0; i <
ARRAY_SIZE(SXGA_s5k4aa); i++) {
329 switch (SXGA_s5k4aa[i][0]) {
337 data[0] = SXGA_s5k4aa[
i][2];
344 data[0] = SXGA_s5k4aa[
i][2];
345 data[1] = SXGA_s5k4aa[
i][3];
352 pr_err(
"Invalid stream command, exiting init\n");
356 err = s5k4aa_set_noise(&sd->
gspca_dev, 0);
362 PDEBUG(D_V4L2,
"Configuring camera for VGA mode");
364 for (i = 0; i <
ARRAY_SIZE(VGA_s5k4aa); i++) {
365 switch (VGA_s5k4aa[i][0]) {
373 data[0] = VGA_s5k4aa[
i][2];
380 data[0] = VGA_s5k4aa[
i][2];
381 data[1] = VGA_s5k4aa[
i][3];
388 pr_err(
"Invalid stream command, exiting init\n");
392 err = s5k4aa_set_noise(&sd->
gspca_dev, 1);
400 err = s5k4aa_set_exposure(&sd->
gspca_dev,
409 err = s5k4aa_set_brightness(&sd->
gspca_dev,
430 u8 data[2] = {0x00, 0x00};
432 switch (init_s5k4aa[i][0]) {
440 data[0] = init_s5k4aa[
i][2];
442 init_s5k4aa[i][1], data, 1);
446 data[0] = init_s5k4aa[
i][2];
447 data[1] = init_s5k4aa[
i][3];
449 init_s5k4aa[i][1], data, 2);
452 pr_info(
"Invalid stream command, exiting init\n");
458 s5k4aa_dump_registers(sd);
465 struct sd *
sd = (
struct sd *) gspca_dev;
469 PDEBUG(D_V4L2,
"Read exposure %d", *val);
476 struct sd *
sd = (
struct sd *) gspca_dev;
482 PDEBUG(D_V4L2,
"Set exposure to %d", val);
486 data = (val >> 8) & 0xff;
496 static int s5k4aa_get_vflip(
struct gspca_dev *gspca_dev,
__s32 *val)
498 struct sd *sd = (
struct sd *) gspca_dev;
502 PDEBUG(D_V4L2,
"Read vertical flip %d", *val);
507 static int s5k4aa_set_vflip(
struct gspca_dev *gspca_dev,
__s32 val)
509 struct sd *sd = (
struct sd *) gspca_dev;
516 PDEBUG(D_V4L2,
"Set vertical flip to %d", val);
544 static int s5k4aa_get_hflip(
struct gspca_dev *gspca_dev,
__s32 *val)
546 struct sd *sd = (
struct sd *) gspca_dev;
550 PDEBUG(D_V4L2,
"Read horizontal flip %d", *val);
555 static int s5k4aa_set_hflip(
struct gspca_dev *gspca_dev,
__s32 val)
557 struct sd *sd = (
struct sd *) gspca_dev;
564 PDEBUG(D_V4L2,
"Set horizontal flip to %d", val);
592 static int s5k4aa_get_gain(
struct gspca_dev *gspca_dev,
__s32 *val)
594 struct sd *sd = (
struct sd *) gspca_dev;
598 PDEBUG(D_V4L2,
"Read gain %d", *val);
602 static int s5k4aa_set_gain(
struct gspca_dev *gspca_dev,
__s32 val)
604 struct sd *sd = (
struct sd *) gspca_dev;
611 PDEBUG(D_V4L2,
"Set gain to %d", val);
622 static int s5k4aa_get_brightness(
struct gspca_dev *gspca_dev,
__s32 *val)
624 struct sd *sd = (
struct sd *) gspca_dev;
628 PDEBUG(D_V4L2,
"Read brightness %d", *val);
632 static int s5k4aa_set_brightness(
struct gspca_dev *gspca_dev,
__s32 val)
634 struct sd *sd = (
struct sd *) gspca_dev;
641 PDEBUG(D_V4L2,
"Set brightness to %d", val);
650 static int s5k4aa_get_noise(
struct gspca_dev *gspca_dev,
__s32 *val)
652 struct sd *sd = (
struct sd *) gspca_dev;
656 PDEBUG(D_V4L2,
"Read noise %d", *val);
660 static int s5k4aa_set_noise(
struct gspca_dev *gspca_dev,
__s32 val)
662 struct sd *sd = (
struct sd *) gspca_dev;
669 PDEBUG(D_V4L2,
"Set noise to %d", val);
684 static void s5k4aa_dump_registers(
struct sd *sd)
689 for (page = 0; page < 16; page++) {
691 pr_info(
"Dumping the s5k4aa register state for page 0x%x\n",
693 for (address = 0; address <= 0xff; address++) {
696 pr_info(
"register 0x%x contains 0x%x\n",
700 pr_info(
"s5k4aa register state dump complete\n");
702 for (page = 0; page < 16; page++) {
704 pr_info(
"Probing for which registers that are read/write for page 0x%x\n",
706 for (address = 0; address <= 0xff; address++) {
707 u8 old_value, ctrl_value, test_value = 0xff;
713 if (ctrl_value == test_value)
714 pr_info(
"register 0x%x is writeable\n",
717 pr_info(
"register 0x%x is read only\n",
724 pr_info(
"Read/write register probing complete\n");