Lines Matching refs:client

60 #define mt9t112_reg_write(ret, client, a, b) \
61 ECHECKER(ret, __mt9t112_reg_write(client, a, b))
62 #define mt9t112_mcu_write(ret, client, a, b) \
63 ECHECKER(ret, __mt9t112_mcu_write(client, a, b))
65 #define mt9t112_reg_mask_set(ret, client, a, b, c) \
66 ECHECKER(ret, __mt9t112_reg_mask_set(client, a, b, c))
67 #define mt9t112_mcu_mask_set(ret, client, a, b, c) \
68 ECHECKER(ret, __mt9t112_mcu_mask_set(client, a, b, c))
70 #define mt9t112_reg_read(ret, client, a) \
71 ECHECKER(ret, __mt9t112_reg_read(client, a))
93 struct i2c_client *client;
143 static struct mt9t112_priv *to_mt9t112(const struct i2c_client *client)
145 return container_of(i2c_get_clientdata(client),
150 static int __mt9t112_reg_read(const struct i2c_client *client, u16 command)
158 msg[0].addr = client->addr;
163 msg[1].addr = client->addr;
172 ret = i2c_transfer(client->adapter, msg, 2);
181 static int __mt9t112_reg_write(const struct i2c_client *client,
194 msg.addr = client->addr;
203 ret = i2c_transfer(client->adapter, &msg, 1);
208 static int __mt9t112_reg_mask_set(const struct i2c_client *client,
211 int val = __mt9t112_reg_read(client, command);
219 return __mt9t112_reg_write(client, command, val);
223 static int __mt9t112_mcu_read(const struct i2c_client *client, u16 command)
227 ret = __mt9t112_reg_write(client, 0x098E, command);
231 return __mt9t112_reg_read(client, 0x0990);
234 static int __mt9t112_mcu_write(const struct i2c_client *client,
239 ret = __mt9t112_reg_write(client, 0x098E, command);
243 return __mt9t112_reg_write(client, 0x0990, data);
246 static int __mt9t112_mcu_mask_set(const struct i2c_client *client,
249 int val = __mt9t112_mcu_read(client, command);
257 return __mt9t112_mcu_write(client, command, val);
260 static int mt9t112_reset(const struct i2c_client *client)
264 mt9t112_reg_mask_set(ret, client, 0x001a, 0x0001, 0x0001);
266 mt9t112_reg_mask_set(ret, client, 0x001a, 0x0001, 0x0000);
275 static int mt9t112_clock_info(const struct i2c_client *client, u32 ext)
283 mt9t112_reg_read(n, client, 0x0012);
290 mt9t112_reg_read(n, client, 0x002a);
297 mt9t112_reg_read(n, client, 0x002c);
300 mt9t112_reg_read(n, client, 0x0010);
305 dev_dbg(&client->dev, "EXTCLK : %10u K %s\n", ext, enable);
309 dev_dbg(&client->dev, "VCO : %10u K %s\n", vco, enable);
313 dev_dbg(&client->dev, "PIXCLK : %10u K %s\n", clk, enable);
317 dev_dbg(&client->dev, "MIPICLK : %10u K %s\n", clk, enable);
321 dev_dbg(&client->dev, "MCU CLK : %10u K %s\n", clk, enable);
325 dev_dbg(&client->dev, "SOC CLK : %10u K %s\n", clk, enable);
329 dev_dbg(&client->dev, "Sensor CLK : %10u K %s\n", clk, enable);
332 dev_dbg(&client->dev, "External sensor : %10u K\n", clk);
336 dev_dbg(&client->dev, "PFD : %10u K %s\n", clk, enable);
342 static int mt9t112_set_a_frame_size(const struct i2c_client *client,
350 mt9t112_mcu_write(ret, client, VAR(26, 0), width);
351 mt9t112_mcu_write(ret, client, VAR(26, 2), height);
354 mt9t112_mcu_write(ret, client, VAR(18, 43), 8 + width);
355 mt9t112_mcu_write(ret, client, VAR(18, 45), 8 + height);
358 mt9t112_mcu_write(ret, client, VAR(18, 2), 4 + hstart);
359 mt9t112_mcu_write(ret, client, VAR(18, 4), 4 + wstart);
362 mt9t112_mcu_write(ret, client, VAR(18, 6), 11 + height + hstart);
363 mt9t112_mcu_write(ret, client, VAR(18, 8), 11 + width + wstart);
365 mt9t112_mcu_write(ret, client, VAR8(1, 0), 0x06);
370 static int mt9t112_set_pll_dividers(const struct i2c_client *client,
379 mt9t112_reg_mask_set(ret, client, 0x0010, 0x3fff, val);
383 mt9t112_reg_mask_set(ret, client, 0x0012, 0x0fff, val);
388 mt9t112_reg_mask_set(ret, client, 0x002A, 0x7fff, val);
392 mt9t112_reg_mask_set(ret, client, 0x002C, 0x100f, val);
397 static int mt9t112_init_pll(const struct i2c_client *client)
399 struct mt9t112_priv *priv = to_mt9t112(client);
402 mt9t112_reg_mask_set(ret, client, 0x0014, 0x003, 0x0001);
405 mt9t112_reg_write(ret, client, 0x0014, 0x2145);
408 mt9t112_set_pll_dividers(client,
421 mt9t112_reg_write(ret, client, 0x0014, 0x2525);
422 mt9t112_reg_write(ret, client, 0x0014, 0x2527);
423 mt9t112_reg_write(ret, client, 0x0014, 0x3427);
424 mt9t112_reg_write(ret, client, 0x0014, 0x3027);
433 mt9t112_reg_write(ret, client, 0x0014, 0x3046);
435 mt9t112_reg_write(ret, client, 0x0016, 0x0400);
436 mt9t112_reg_write(ret, client, 0x0022, 0x0190);
437 mt9t112_reg_write(ret, client, 0x3B84, 0x0212);
440 mt9t112_reg_write(ret, client, 0x002E, 0x0500);
442 mt9t112_reg_mask_set(ret, client, 0x0018, 0x0002, 0x0002);
443 mt9t112_reg_mask_set(ret, client, 0x3B82, 0x0004, 0x0004);
446 mt9t112_reg_mask_set(ret, client, 0x0018, 0x0004, 0x0004);
449 mt9t112_reg_mask_set(ret, client, 0x0018, 0x0001, 0);
457 mt9t112_reg_write(ret, client, 0x0614, 0x0001);
459 mt9t112_reg_write(ret, client, 0x0614, 0x0001);
461 mt9t112_reg_write(ret, client, 0x0614, 0x0001);
463 mt9t112_reg_write(ret, client, 0x0614, 0x0001);
465 mt9t112_reg_write(ret, client, 0x0614, 0x0001);
467 mt9t112_reg_write(ret, client, 0x0614, 0x0001);
472 mt9t112_reg_read(data, client, 0x0018);
482 static int mt9t112_init_setting(const struct i2c_client *client)
487 mt9t112_mcu_mask_set(ret, client, VAR(26, 160), 0x0040, 0x0000);
490 mt9t112_mcu_write(ret, client, VAR(18, 12), 0x0024);
493 mt9t112_mcu_write(ret, client, VAR(18, 15), 0x00CC);
496 mt9t112_mcu_write(ret, client, VAR(18, 17), 0x01f1);
499 mt9t112_mcu_write(ret, client, VAR(18, 19), 0x00fF);
502 mt9t112_mcu_write(ret, client, VAR(18, 29), 0x032D);
505 mt9t112_mcu_write(ret, client, VAR(18, 31), 0x073a);
508 mt9t112_mcu_write(ret, client, VAR(18, 37), 0x07d0);
511 mt9t112_mcu_mask_set(ret, client, VAR(27, 160), 0x0040, 0x0000);
514 mt9t112_mcu_write(ret, client, VAR(18, 74), 0x004);
517 mt9t112_mcu_write(ret, client, VAR(18, 76), 0x004);
520 mt9t112_mcu_write(ret, client, VAR(18, 78), 0x60B);
523 mt9t112_mcu_write(ret, client, VAR(18, 80), 0x80B);
526 mt9t112_mcu_write(ret, client, VAR(18, 87), 0x008C);
529 mt9t112_mcu_write(ret, client, VAR(18, 89), 0x01F1);
532 mt9t112_mcu_write(ret, client, VAR(18, 91), 0x00FF);
535 mt9t112_mcu_write(ret, client, VAR(18, 101), 0x0668);
538 mt9t112_mcu_write(ret, client, VAR(18, 103), 0x0AF0);
541 mt9t112_mcu_write(ret, client, VAR(18, 109), 0x0AF0);
552 mt9t112_mcu_write(ret, client, VAR8(8, 5), 0x01);
555 mt9t112_mcu_write(ret, client, VAR(27, 17), 0x0003);
558 mt9t112_mcu_write(ret, client, VAR(26, 17), 0x0003);
565 mt9t112_mcu_write(ret, client, VAR8(18, 165), 0x25);
568 mt9t112_mcu_write(ret, client, VAR8(18, 166), 0x28);
571 mt9t112_mcu_write(ret, client, VAR8(18, 167), 0x2C);
574 mt9t112_mcu_write(ret, client, VAR8(18, 168), 0x2F);
577 mt9t112_mcu_write(ret, client, VAR8(18, 68), 0xBA);
581 mt9t112_mcu_write(ret, client, VAR8(18, 303), 0x00);
584 mt9t112_mcu_write(ret, client, VAR8(18, 69), 0x9B);
588 mt9t112_mcu_write(ret, client, VAR8(18, 301), 0x00);
591 mt9t112_mcu_write(ret, client, VAR8(18, 140), 0x82);
595 mt9t112_mcu_write(ret, client, VAR8(18, 304), 0x00);
598 mt9t112_mcu_write(ret, client, VAR8(18, 141), 0x6D);
602 mt9t112_mcu_write(ret, client, VAR8(18, 302), 0x00);
605 mt9t112_mcu_write(ret, client, VAR8(8, 2), 0x10);
608 mt9t112_mcu_write(ret, client, VAR8(8, 9), 0x02);
611 mt9t112_mcu_write(ret, client, VAR8(8, 10), 0x03);
614 mt9t112_mcu_write(ret, client, VAR8(8, 12), 0x0A);
617 mt9t112_mcu_write(ret, client, VAR(18, 70), 0x0014);
620 mt9t112_mcu_write(ret, client, VAR(18, 142), 0x0014);
626 mt9t112_mcu_write(ret, client, VAR8(18, 0x0044), 133);
627 mt9t112_mcu_write(ret, client, VAR8(18, 0x0045), 110);
628 mt9t112_mcu_write(ret, client, VAR8(18, 0x008c), 130);
629 mt9t112_mcu_write(ret, client, VAR8(18, 0x008d), 108);
631 mt9t112_mcu_write(ret, client, VAR8(18, 0x00A5), 27);
632 mt9t112_mcu_write(ret, client, VAR8(18, 0x00a6), 30);
633 mt9t112_mcu_write(ret, client, VAR8(18, 0x00a7), 32);
634 mt9t112_mcu_write(ret, client, VAR8(18, 0x00a8), 35);
639 static int mt9t112_auto_focus_setting(const struct i2c_client *client)
643 mt9t112_mcu_write(ret, client, VAR(12, 13), 0x000F);
644 mt9t112_mcu_write(ret, client, VAR(12, 23), 0x0F0F);
645 mt9t112_mcu_write(ret, client, VAR8(1, 0), 0x06);
647 mt9t112_reg_write(ret, client, 0x0614, 0x0000);
649 mt9t112_mcu_write(ret, client, VAR8(1, 0), 0x05);
650 mt9t112_mcu_write(ret, client, VAR8(12, 2), 0x02);
651 mt9t112_mcu_write(ret, client, VAR(12, 3), 0x0002);
652 mt9t112_mcu_write(ret, client, VAR(17, 3), 0x8001);
653 mt9t112_mcu_write(ret, client, VAR(17, 11), 0x0025);
654 mt9t112_mcu_write(ret, client, VAR(17, 13), 0x0193);
655 mt9t112_mcu_write(ret, client, VAR8(17, 33), 0x18);
656 mt9t112_mcu_write(ret, client, VAR8(1, 0), 0x05);
661 static int mt9t112_auto_focus_trigger(const struct i2c_client *client)
665 mt9t112_mcu_write(ret, client, VAR8(12, 25), 0x01);
670 static int mt9t112_init_camera(const struct i2c_client *client)
674 ECHECKER(ret, mt9t112_reset(client));
675 ECHECKER(ret, mt9t112_init_pll(client));
676 ECHECKER(ret, mt9t112_init_setting(client));
677 ECHECKER(ret, mt9t112_auto_focus_setting(client));
679 mt9t112_reg_mask_set(ret, client, 0x0018, 0x0004, 0);
682 mt9t112_reg_write(ret, client, 0x3084, 0x2409);
683 mt9t112_reg_write(ret, client, 0x3092, 0x0A49);
684 mt9t112_reg_write(ret, client, 0x3094, 0x4949);
685 mt9t112_reg_write(ret, client, 0x3096, 0x4950);
692 mt9t112_mcu_write(ret, client, VAR(26, 160), 0x0A2E);
693 mt9t112_mcu_write(ret, client, VAR(27, 160), 0x0A2E);
699 mt9t112_mcu_write(ret, client, VAR(27, 144), 0x0CB4);
705 mt9t112_mcu_write(ret, client, VAR8(27, 142), 0x01);
708 mt9t112_reg_write(ret, client, 0x316C, 0x350F);
711 mt9t112_reg_write(ret, client, 0x1E, 0x777);
724 struct i2c_client *client = v4l2_get_subdevdata(sd);
728 mt9t112_reg_read(ret, client, reg->reg);
738 struct i2c_client *client = v4l2_get_subdevdata(sd);
741 mt9t112_reg_write(ret, client, reg->reg, reg->val);
776 struct i2c_client *client = v4l2_get_subdevdata(sd);
777 struct mt9t112_priv *priv = to_mt9t112(client);
796 struct i2c_client *client = v4l2_get_subdevdata(sd);
797 struct mt9t112_priv *priv = to_mt9t112(client);
809 mt9t112_set_a_frame_size(client, VGA_WIDTH, VGA_HEIGHT);
817 ECHECKER(ret, mt9t112_init_camera(client));
820 mt9t112_reg_write(ret, client, 0x3C20, param);
827 mt9t112_mcu_write(ret, client, VAR(26, 7), priv->format->fmt);
828 mt9t112_mcu_write(ret, client, VAR(26, 9), priv->format->order);
829 mt9t112_mcu_write(ret, client, VAR8(1, 0), 0x06);
831 mt9t112_set_a_frame_size(client, priv->frame.width, priv->frame.height);
833 ECHECKER(ret, mt9t112_auto_focus_trigger(client));
835 dev_dbg(&client->dev, "format : %d\n", priv->format->code);
836 dev_dbg(&client->dev, "size : %d x %d\n",
840 CLOCK_INFO(client, EXT_CLOCK);
878 struct i2c_client *client = v4l2_get_subdevdata(sd);
879 struct mt9t112_priv *priv = to_mt9t112(client);
903 struct i2c_client *client = v4l2_get_subdevdata(sd);
904 struct mt9t112_priv *priv = to_mt9t112(client);
919 struct i2c_client *client = v4l2_get_subdevdata(sd);
920 struct mt9t112_priv *priv = to_mt9t112(client);
937 struct i2c_client *client = v4l2_get_subdevdata(sd);
938 struct mt9t112_priv *priv = to_mt9t112(client);
959 struct i2c_client *client = v4l2_get_subdevdata(sd);
961 struct mt9t112_priv *priv = to_mt9t112(client);
993 struct i2c_client *client = v4l2_get_subdevdata(sd);
994 struct mt9t112_priv *priv = to_mt9t112(client);
1025 static int mt9t112_camera_probe(struct i2c_client *client)
1027 struct mt9t112_priv *priv = to_mt9t112(client);
1037 mt9t112_reg_read(chipid, client, 0x0000);
1049 dev_err(&client->dev, "Product ID error %04x\n", chipid);
1054 dev_info(&client->dev, "%s chip ID %04x\n", devname, chipid);
1062 static int mt9t112_probe(struct i2c_client *client)
1067 if (!client->dev.platform_data) {
1068 dev_err(&client->dev, "mt9t112: missing platform data!\n");
1072 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
1076 priv->info = client->dev.platform_data;
1079 v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
1081 priv->clk = devm_clk_get(&client->dev, "extclk");
1085 dev_err(&client->dev, "Unable to get clock \"extclk\"\n");
1089 priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
1092 dev_err(&client->dev, "Unable to get gpio \"standby\"\n");
1096 ret = mt9t112_camera_probe(client);
1103 static void mt9t112_remove(struct i2c_client *client)
1105 struct mt9t112_priv *priv = to_mt9t112(client);