aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp/i2c/imx/imx.h
blob: 36b3f3a5a41fd33b485f6581b5ebe57622254fcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
/*
 * Support for Sony IMX camera sensor.
 *
 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 */

#ifndef __IMX_H__
#define __IMX_H__
#include "../../include/linux/atomisp_platform.h"
#include "../../include/linux/atomisp.h"
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/videodev2.h>
#include <linux/v4l2-mediabus.h>
#include <media/media-entity.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>
#include "imx175.h"
#include "imx135.h"
#include "imx134.h"
#include "imx132.h"
#include "imx208.h"
#include "imx219.h"
#include "imx227.h"

#define IMX_MCLK		192

/* TODO - This should be added into include/linux/videodev2.h */
#ifndef V4L2_IDENT_IMX
#define V4L2_IDENT_IMX	8245
#endif

#define IMX_MAX_AE_LUT_LENGTH	5
/*
 * imx System control registers
 */
#define IMX_MASK_5BIT	0x1F
#define IMX_MASK_4BIT	0xF
#define IMX_MASK_3BIT	0x7
#define IMX_MASK_2BIT	0x3
#define IMX_MASK_8BIT	0xFF
#define IMX_MASK_11BIT	0x7FF
#define IMX_INTG_BUF_COUNT		2

#define IMX_FINE_INTG_TIME		0x1E8

#define IMX_VT_PIX_CLK_DIV		0x0301
#define IMX_VT_SYS_CLK_DIV		0x0303
#define IMX_PRE_PLL_CLK_DIV		0x0305
#define IMX227_IOP_PRE_PLL_CLK_DIV	0x030D
#define IMX227_PLL_MULTIPLIER		0x0306
#define IMX227_IOP_PLL_MULTIPLIER	0x030E
#define IMX227_PLL_MULTI_DRIVE		0x0310
#define IMX227_OP_PIX_CLK_DIV		0x0309
#define IMX227_OP_SYS_CLK_DIV		0x030B
#define IMX_PLL_MULTIPLIER		0x030C
#define IMX_OP_PIX_DIV			0x0309
#define IMX_OP_SYS_DIV			0x030B
#define IMX_FRAME_LENGTH_LINES		0x0340
#define IMX_LINE_LENGTH_PIXELS		0x0342
#define IMX_COARSE_INTG_TIME_MIN	0x1004
#define IMX_COARSE_INTG_TIME_MAX	0x1006
#define IMX_BINNING_ENABLE		0x0390
#define IMX227_BINNING_ENABLE		0x0900
#define IMX_BINNING_TYPE		0x0391
#define IMX227_BINNING_TYPE		0x0901
#define IMX_READ_MODE			0x0390
#define IMX227_READ_MODE		0x0900

#define IMX_HORIZONTAL_START_H 0x0344
#define IMX_VERTICAL_START_H 0x0346
#define IMX_HORIZONTAL_END_H 0x0348
#define IMX_VERTICAL_END_H 0x034a
#define IMX_HORIZONTAL_OUTPUT_SIZE_H 0x034c
#define IMX_VERTICAL_OUTPUT_SIZE_H 0x034e

/* Post Divider setting register for imx132 and imx208 */
#define IMX132_208_VT_RGPLTD		0x30A4

/* Multiplier setting register for imx132, imx208, and imx219 */
#define IMX132_208_219_PLL_MULTIPLIER		0x0306

#define IMX_COARSE_INTEGRATION_TIME		0x0202
#define IMX_TEST_PATTERN_MODE			0x0600
#define IMX_TEST_PATTERN_COLOR_R		0x0602
#define IMX_TEST_PATTERN_COLOR_GR		0x0604
#define IMX_TEST_PATTERN_COLOR_B		0x0606
#define IMX_TEST_PATTERN_COLOR_GB		0x0608
#define IMX_IMG_ORIENTATION			0x0101
#define IMX_VFLIP_BIT			2
#define IMX_HFLIP_BIT			1
#define IMX_GLOBAL_GAIN			0x0205
#define IMX_SHORT_AGC_GAIN		0x0233
#define IMX_DGC_ADJ		0x020E
#define IMX_DGC_LEN		10
#define IMX227_DGC_LEN		4
#define IMX_MAX_EXPOSURE_SUPPORTED 0xfffb
#define IMX_MAX_GLOBAL_GAIN_SUPPORTED 0x00ff
#define IMX_MAX_DIGITAL_GAIN_SUPPORTED 0x0fff

#define MAX_FMTS 1
#define IMX_OTP_DATA_SIZE		1280

#define IMX_SUBDEV_PREFIX "imx"
#define IMX_DRIVER	"imx1x5"

/* Sensor ids from identification register */
#define IMX_NAME_134	"imx134"
#define IMX_NAME_135	"imx135"
#define IMX_NAME_175	"imx175"
#define IMX_NAME_132	"imx132"
#define IMX_NAME_208	"imx208"
#define IMX_NAME_219	"imx219"
#define IMX_NAME_227	"imx227"
#define IMX175_ID	0x0175
#define IMX135_ID	0x0135
#define IMX134_ID	0x0134
#define IMX132_ID	0x0132
#define IMX208_ID	0x0208
#define IMX219_ID	0x0219
#define IMX227_ID	0x0227

/* Sensor id based on i2c_device_id table
 * (Fuji module can not be detected based on sensor registers) */
#define IMX135_FUJI_ID			0x0136
#define IMX_NAME_135_FUJI		"imx135fuji"

/* imx175 - use dw9714 vcm */
#define IMX175_MERRFLD 0x175
#define IMX175_VALLEYVIEW 0x176
#define IMX135_SALTBAY 0x135
#define IMX135_VICTORIABAY 0x136
#define IMX132_SALTBAY 0x132
#define IMX134_VALLEYVIEW 0x134
#define IMX208_MOFD_PD2 0x208
#define IMX219_MFV0_PRH 0x219
#define IMX227_SAND 0x227

/* otp - specific settings */
#define E2PROM_ADDR 0xa0
#define E2PROM_LITEON_12P1BA869D_ADDR 0xa0
#define E2PROM_ABICO_SS89A839_ADDR 0xa8
#define DEFAULT_OTP_SIZE 1280
#define IMX135_OTP_SIZE 1280
#define IMX219_OTP_SIZE 2048
#define IMX227_OTP_SIZE 2560
#define E2PROM_LITEON_12P1BA869D_SIZE 544

#define IMX_ID_DEFAULT	0x0000
#define IMX132_175_208_219_CHIP_ID	0x0000
#define IMX134_135_CHIP_ID	0x0016
#define IMX134_135_227_CHIP_ID	0x0016

#define IMX175_RES_WIDTH_MAX	3280
#define IMX175_RES_HEIGHT_MAX	2464
#define IMX135_RES_WIDTH_MAX	4208
#define IMX135_RES_HEIGHT_MAX	3120
#define IMX132_RES_WIDTH_MAX	1936
#define IMX132_RES_HEIGHT_MAX	1096
#define IMX134_RES_WIDTH_MAX	3280
#define IMX134_RES_HEIGHT_MAX	2464
#define IMX208_RES_WIDTH_MAX	1936
#define IMX208_RES_HEIGHT_MAX	1096
#define IMX219_RES_WIDTH_MAX	3280
#define IMX219_RES_HEIGHT_MAX	2464
#define IMX227_RES_WIDTH_MAX	2400
#define IMX227_RES_HEIGHT_MAX	2720

/* Defines for lens/VCM */
#define IMX_FOCAL_LENGTH_NUM	369	/*3.69mm*/
#define IMX_FOCAL_LENGTH_DEM	100
#define IMX_F_NUMBER_DEFAULT_NUM	22
#define IMX_F_NUMBER_DEM	10
#define IMX_INVALID_CONFIG	0xffffffff
#define IMX_MAX_FOCUS_POS	1023
#define IMX_MAX_FOCUS_NEG	(-1023)
#define IMX_VCM_SLEW_STEP_MAX	0x3f
#define IMX_VCM_SLEW_TIME_MAX	0x1f

#define IMX_BIN_FACTOR_MAX			4
#define IMX_INTEGRATION_TIME_MARGIN	4
/*
 * focal length bits definition:
 * bits 31-16: numerator, bits 15-0: denominator
 */
#define IMX_FOCAL_LENGTH_DEFAULT 0x1710064

/*
 * current f-number bits definition:
 * bits 31-16: numerator, bits 15-0: denominator
 */
#define IMX_F_NUMBER_DEFAULT 0x16000a

/*
 * f-number range bits definition:
 * bits 31-24: max f-number numerator
 * bits 23-16: max f-number denominator
 * bits 15-8: min f-number numerator
 * bits 7-0: min f-number denominator
 */
#define IMX_F_NUMBER_RANGE 0x160a160a

struct imx_vcm {
	int (*power_up)(struct v4l2_subdev *sd);
	int (*power_down)(struct v4l2_subdev *sd);
	int (*init)(struct v4l2_subdev *sd);
	int (*t_focus_vcm)(struct v4l2_subdev *sd, u16 val);
	int (*t_focus_abs)(struct v4l2_subdev *sd, s32 value);
	int (*t_focus_abs_init)(struct v4l2_subdev *sd);
	int (*t_focus_rel)(struct v4l2_subdev *sd, s32 value);
	int (*q_focus_status)(struct v4l2_subdev *sd, s32 *value);
	int (*q_focus_abs)(struct v4l2_subdev *sd, s32 *value);
	int (*t_vcm_slew)(struct v4l2_subdev *sd, s32 value);
	int (*t_vcm_timing)(struct v4l2_subdev *sd, s32 value);
};

struct imx_otp {
	void * (*otp_read)(struct v4l2_subdev *sd, u8 dev_addr,
		u32 start_addr, u32 size);
	u32 start_addr;
	u32 size;
	u8 dev_addr;
};

struct max_res {
	int res_max_width;
	int res_max_height;
};

struct max_res imx_max_res[] = {
	[IMX175_ID] = {
		.res_max_width = IMX175_RES_WIDTH_MAX,
		.res_max_height = IMX175_RES_HEIGHT_MAX,
	},
	[IMX135_ID] = {
		.res_max_width = IMX135_RES_WIDTH_MAX,
		.res_max_height = IMX135_RES_HEIGHT_MAX,
	},
	[IMX132_ID] = {
		.res_max_width = IMX132_RES_WIDTH_MAX,
		.res_max_height = IMX132_RES_HEIGHT_MAX,
	},
	[IMX134_ID] = {
		.res_max_width = IMX134_RES_WIDTH_MAX,
		.res_max_height = IMX134_RES_HEIGHT_MAX,
	},
	[IMX208_ID] = {
		.res_max_width = IMX208_RES_WIDTH_MAX,
		.res_max_height = IMX208_RES_HEIGHT_MAX,
	},
	[IMX219_ID] = {
		.res_max_width = IMX219_RES_WIDTH_MAX,
		.res_max_height = IMX219_RES_HEIGHT_MAX,
	},
	[IMX227_ID] = {
		.res_max_width = IMX227_RES_WIDTH_MAX,
		.res_max_height = IMX227_RES_HEIGHT_MAX,
	},
};

struct imx_settings {
	struct imx_reg const *init_settings;
	struct imx_resolution *res_preview;
	struct imx_resolution *res_still;
	struct imx_resolution *res_video;
	int n_res_preview;
	int n_res_still;
	int n_res_video;
};

struct imx_settings imx_sets[] = {
	[IMX175_MERRFLD] = {
		.init_settings = imx175_init_settings,
		.res_preview = imx175_res_preview,
		.res_still = imx175_res_still,
		.res_video = imx175_res_video,
		.n_res_preview = ARRAY_SIZE(imx175_res_preview),
		.n_res_still = ARRAY_SIZE(imx175_res_still),
		.n_res_video = ARRAY_SIZE(imx175_res_video),
	},
	[IMX175_VALLEYVIEW] = {
		.init_settings = imx175_init_settings,
		.res_preview = imx175_res_preview,
		.res_still = imx175_res_still,
		.res_video = imx175_res_video,
		.n_res_preview = ARRAY_SIZE(imx175_res_preview),
		.n_res_still = ARRAY_SIZE(imx175_res_still),
		.n_res_video = ARRAY_SIZE(imx175_res_video),
	},
	[IMX135_SALTBAY] = {
		.init_settings = imx135_init_settings,
		.res_preview = imx135_res_preview,
		.res_still = imx135_res_still,
		.res_video = imx135_res_video,
		.n_res_preview = ARRAY_SIZE(imx135_res_preview),
		.n_res_still = ARRAY_SIZE(imx135_res_still),
		.n_res_video = ARRAY_SIZE(imx135_res_video),
	},
	[IMX135_VICTORIABAY] = {
		.init_settings = imx135_init_settings,
		.res_preview = imx135_res_preview_mofd,
		.res_still = imx135_res_still_mofd,
		.res_video = imx135_res_video,
		.n_res_preview = ARRAY_SIZE(imx135_res_preview_mofd),
		.n_res_still = ARRAY_SIZE(imx135_res_still_mofd),
		.n_res_video = ARRAY_SIZE(imx135_res_video),
	},
	[IMX132_SALTBAY] = {
		.init_settings = imx132_init_settings,
		.res_preview = imx132_res_preview,
		.res_still = imx132_res_still,
		.res_video = imx132_res_video,
		.n_res_preview = ARRAY_SIZE(imx132_res_preview),
		.n_res_still = ARRAY_SIZE(imx132_res_still),
		.n_res_video = ARRAY_SIZE(imx132_res_video),
	},
	[IMX134_VALLEYVIEW] = {
		.init_settings = imx134_init_settings,
		.res_preview = imx134_res_preview,
		.res_still = imx134_res_still,
		.res_video = imx134_res_video,
		.n_res_preview = ARRAY_SIZE(imx134_res_preview),
		.n_res_still = ARRAY_SIZE(imx134_res_still),
		.n_res_video = ARRAY_SIZE(imx134_res_video),
	},
	[IMX208_MOFD_PD2] = {
		.init_settings = imx208_init_settings,
		.res_preview = imx208_res_preview,
		.res_still = imx208_res_still,
		.res_video = imx208_res_video,
		.n_res_preview = ARRAY_SIZE(imx208_res_preview),
		.n_res_still = ARRAY_SIZE(imx208_res_still),
		.n_res_video = ARRAY_SIZE(imx208_res_video),
	},
	[IMX219_MFV0_PRH] = {
		.init_settings = imx219_init_settings,
		.res_preview = imx219_res_preview,
		.res_still = imx219_res_still,
		.res_video = imx219_res_video,
		.n_res_preview = ARRAY_SIZE(imx219_res_preview),
		.n_res_still = ARRAY_SIZE(imx219_res_still),
		.n_res_video = ARRAY_SIZE(imx219_res_video),
	},
	[IMX227_SAND] = {
		.init_settings = imx227_init_settings,
		.res_preview = imx227_res_preview,
		.res_still = imx227_res_still,
		.res_video = imx227_res_video,
		.n_res_preview = ARRAY_SIZE(imx227_res_preview),
		.n_res_still = ARRAY_SIZE(imx227_res_still),
		.n_res_video = ARRAY_SIZE(imx227_res_video),
	},
};

struct imx_reg_addr {
	u16 frame_length_lines;
	u16 line_length_pixels;
	u16 horizontal_start_h;
	u16 vertical_start_h;
	u16 horizontal_end_h;
	u16 vertical_end_h;
	u16 horizontal_output_size_h;
	u16 vertical_output_size_h;
	u16 coarse_integration_time;
	u16 img_orientation;
	u16 global_gain;
	u16 dgc_adj;
};

struct imx_reg_addr imx_addr = {
	IMX_FRAME_LENGTH_LINES,
	IMX_LINE_LENGTH_PIXELS,
	IMX_HORIZONTAL_START_H,
	IMX_VERTICAL_START_H,
	IMX_HORIZONTAL_END_H,
	IMX_VERTICAL_END_H,
	IMX_HORIZONTAL_OUTPUT_SIZE_H,
	IMX_VERTICAL_OUTPUT_SIZE_H,
	IMX_COARSE_INTEGRATION_TIME,
	IMX_IMG_ORIENTATION,
	IMX_GLOBAL_GAIN,
	IMX_DGC_ADJ,
};

struct imx_reg_addr imx219_addr = {
	IMX219_FRAME_LENGTH_LINES,
	IMX219_LINE_LENGTH_PIXELS,
	IMX219_HORIZONTAL_START_H,
	IMX219_VERTICAL_START_H,
	IMX219_HORIZONTAL_END_H,
	IMX219_VERTICAL_END_H,
	IMX219_HORIZONTAL_OUTPUT_SIZE_H,
	IMX219_VERTICAL_OUTPUT_SIZE_H,
	IMX219_COARSE_INTEGRATION_TIME,
	IMX219_IMG_ORIENTATION,
	IMX219_GLOBAL_GAIN,
	IMX219_DGC_ADJ,
};

#define	v4l2_format_capture_type_entry(_width, _height, \
		_pixelformat, _bytesperline, _colorspace) \
	{\
		.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,\
		.fmt.pix.width = (_width),\
		.fmt.pix.height = (_height),\
		.fmt.pix.pixelformat = (_pixelformat),\
		.fmt.pix.bytesperline = (_bytesperline),\
		.fmt.pix.colorspace = (_colorspace),\
		.fmt.pix.sizeimage = (_height)*(_bytesperline),\
	}

#define	s_output_format_entry(_width, _height, _pixelformat, \
		_bytesperline, _colorspace, _fps) \
	{\
		.v4l2_fmt = v4l2_format_capture_type_entry(_width, \
			_height, _pixelformat, _bytesperline, \
				_colorspace),\
		.fps = (_fps),\
	}

#define	s_output_format_reg_entry(_width, _height, _pixelformat, \
		_bytesperline, _colorspace, _fps, _reg_setting) \
	{\
		.s_fmt = s_output_format_entry(_width, _height,\
				_pixelformat, _bytesperline, \
				_colorspace, _fps),\
		.reg_setting = (_reg_setting),\
	}

/* imx device structure */
struct imx_device {
	struct v4l2_subdev sd;
	struct media_pad pad;
	struct v4l2_mbus_framefmt format;
	struct camera_sensor_platform_data *platform_data;
	struct mutex input_lock; /* serialize sensor's ioctl */
	int fmt_idx;
	int status;
	int streaming;
	int power;
	int run_mode;
	int vt_pix_clk_freq_mhz;
	int fps_index;
	u32 focus;
	u16 sensor_id;			/* Sensor id from registers */
	u16 i2c_id;			/* Sensor id from i2c_device_id */
	u16 coarse_itg;
	u16 fine_itg;
	u16 digital_gain;
	u16 gain;
	u16 pixels_per_line;
	u16 lines_per_frame;
	u8 targetfps;
	u8 fps;
	const struct imx_reg *regs;
	u8 res;
	u8 type;
	u8 sensor_revision;
	u8 *otp_data;
	struct imx_settings *mode_tables;
	struct imx_vcm *vcm_driver;
	struct imx_otp *otp_driver;
	const struct imx_resolution *curr_res_table;
	int entries_curr_table;
	const struct firmware *fw;
	struct imx_reg_addr *reg_addr;
	const struct imx_reg *param_hold;
	const struct imx_reg *param_update;

	/* used for h/b blank tuning */
	struct v4l2_ctrl_handler ctrl_handler;
	struct v4l2_ctrl *pixel_rate;
	struct v4l2_ctrl *h_blank;
	struct v4l2_ctrl *v_blank;
	struct v4l2_ctrl *link_freq;
	struct v4l2_ctrl *h_flip;
	struct v4l2_ctrl *v_flip;

	/* Test pattern control */
	struct v4l2_ctrl *tp_mode;
	struct v4l2_ctrl *tp_r;
	struct v4l2_ctrl *tp_gr;
	struct v4l2_ctrl *tp_gb;
	struct v4l2_ctrl *tp_b;

	/* FIXME! */
	bool new_res_sel_method;
};

#define to_imx_sensor(x) container_of(x, struct imx_device, sd)

#define IMX_MAX_WRITE_BUF_SIZE	32
struct imx_write_buffer {
	u16 addr;
	u8 data[IMX_MAX_WRITE_BUF_SIZE];
};

struct imx_write_ctrl {
	int index;
	struct imx_write_buffer buffer;
};

static const struct imx_reg imx_soft_standby[] = {
	{IMX_8BIT, 0x0100, 0x00},
	{IMX_TOK_TERM, 0, 0}
};

static const struct imx_reg imx_streaming[] = {
	{IMX_8BIT, 0x0100, 0x01},
	{IMX_TOK_TERM, 0, 0}
};

static const struct imx_reg imx_param_hold[] = {
	{IMX_8BIT, 0x0104, 0x01},	/* GROUPED_PARAMETER_HOLD */
	{IMX_TOK_TERM, 0, 0}
};

static const struct imx_reg imx_param_update[] = {
	{IMX_8BIT, 0x0104, 0x00},	/* GROUPED_PARAMETER_HOLD */
	{IMX_TOK_TERM, 0, 0}
};

static const struct imx_reg imx219_param_hold[] = {
	{IMX_TOK_TERM, 0, 0}
};

static const struct imx_reg imx219_param_update[] = {
	{IMX_TOK_TERM, 0, 0}
};

extern int ad5816g_vcm_power_up(struct v4l2_subdev *sd);
extern int ad5816g_vcm_power_down(struct v4l2_subdev *sd);
extern int ad5816g_vcm_init(struct v4l2_subdev *sd);

extern int ad5816g_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
extern int ad5816g_t_focus_abs(struct v4l2_subdev *sd, s32 value);
extern int ad5816g_t_focus_rel(struct v4l2_subdev *sd, s32 value);
extern int ad5816g_q_focus_status(struct v4l2_subdev *sd, s32 *value);
extern int ad5816g_q_focus_abs(struct v4l2_subdev *sd, s32 *value);
extern int ad5816g_t_vcm_slew(struct v4l2_subdev *sd, s32 value);
extern int ad5816g_t_vcm_timing(struct v4l2_subdev *sd, s32 value);

extern int drv201_vcm_power_up(struct v4l2_subdev *sd);
extern int drv201_vcm_power_down(struct v4l2_subdev *sd);
extern int drv201_vcm_init(struct v4l2_subdev *sd);

extern int drv201_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
extern int drv201_t_focus_abs(struct v4l2_subdev *sd, s32 value);
extern int drv201_t_focus_rel(struct v4l2_subdev *sd, s32 value);
extern int drv201_q_focus_status(struct v4l2_subdev *sd, s32 *value);
extern int drv201_q_focus_abs(struct v4l2_subdev *sd, s32 *value);
extern int drv201_t_vcm_slew(struct v4l2_subdev *sd, s32 value);
extern int drv201_t_vcm_timing(struct v4l2_subdev *sd, s32 value);

extern int dw9714_vcm_power_up(struct v4l2_subdev *sd);
extern int dw9714_vcm_power_down(struct v4l2_subdev *sd);
extern int dw9714_vcm_init(struct v4l2_subdev *sd);

extern int dw9714_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
extern int dw9714_t_focus_abs(struct v4l2_subdev *sd, s32 value);
extern int dw9714_t_focus_abs_init(struct v4l2_subdev *sd);
extern int dw9714_t_focus_rel(struct v4l2_subdev *sd, s32 value);
extern int dw9714_q_focus_status(struct v4l2_subdev *sd, s32 *value);
extern int dw9714_q_focus_abs(struct v4l2_subdev *sd, s32 *value);
extern int dw9714_t_vcm_slew(struct v4l2_subdev *sd, s32 value);
extern int dw9714_t_vcm_timing(struct v4l2_subdev *sd, s32 value);

extern int dw9719_vcm_power_up(struct v4l2_subdev *sd);
extern int dw9719_vcm_power_down(struct v4l2_subdev *sd);
extern int dw9719_vcm_init(struct v4l2_subdev *sd);

extern int dw9719_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
extern int dw9719_t_focus_abs(struct v4l2_subdev *sd, s32 value);
extern int dw9719_t_focus_rel(struct v4l2_subdev *sd, s32 value);
extern int dw9719_q_focus_status(struct v4l2_subdev *sd, s32 *value);
extern int dw9719_q_focus_abs(struct v4l2_subdev *sd, s32 *value);
extern int dw9719_t_vcm_slew(struct v4l2_subdev *sd, s32 value);
extern int dw9719_t_vcm_timing(struct v4l2_subdev *sd, s32 value);

extern int dw9718_vcm_power_up(struct v4l2_subdev *sd);
extern int dw9718_vcm_power_down(struct v4l2_subdev *sd);
extern int dw9718_vcm_init(struct v4l2_subdev *sd);

extern int dw9718_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
extern int dw9718_t_focus_abs(struct v4l2_subdev *sd, s32 value);
extern int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value);
extern int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value);
extern int dw9718_q_focus_abs(struct v4l2_subdev *sd, s32 *value);
extern int dw9718_t_vcm_slew(struct v4l2_subdev *sd, s32 value);
extern int dw9718_t_vcm_timing(struct v4l2_subdev *sd, s32 value);

extern int vcm_power_up(struct v4l2_subdev *sd);
extern int vcm_power_down(struct v4l2_subdev *sd);

struct imx_vcm imx_vcms[] = {
	[IMX175_MERRFLD] = {
		.power_up = drv201_vcm_power_up,
		.power_down = drv201_vcm_power_down,
		.init = drv201_vcm_init,
		.t_focus_vcm = drv201_t_focus_vcm,
		.t_focus_abs = drv201_t_focus_abs,
		.t_focus_abs_init = NULL,
		.t_focus_rel = drv201_t_focus_rel,
		.q_focus_status = drv201_q_focus_status,
		.q_focus_abs = drv201_q_focus_abs,
		.t_vcm_slew = drv201_t_vcm_slew,
		.t_vcm_timing = drv201_t_vcm_timing,
	},
	[IMX175_VALLEYVIEW] = {
		.power_up = dw9714_vcm_power_up,
		.power_down = dw9714_vcm_power_down,
		.init = dw9714_vcm_init,
		.t_focus_vcm = dw9714_t_focus_vcm,
		.t_focus_abs = dw9714_t_focus_abs,
		.t_focus_abs_init = NULL,
		.t_focus_rel = dw9714_t_focus_rel,
		.q_focus_status = dw9714_q_focus_status,
		.q_focus_abs = dw9714_q_focus_abs,
		.t_vcm_slew = dw9714_t_vcm_slew,
		.t_vcm_timing = dw9714_t_vcm_timing,
	},
	[IMX135_SALTBAY] = {
		.power_up = ad5816g_vcm_power_up,
		.power_down = ad5816g_vcm_power_down,
		.init = ad5816g_vcm_init,
		.t_focus_vcm = ad5816g_t_focus_vcm,
		.t_focus_abs = ad5816g_t_focus_abs,
		.t_focus_abs_init = NULL,
		.t_focus_rel = ad5816g_t_focus_rel,
		.q_focus_status = ad5816g_q_focus_status,
		.q_focus_abs = ad5816g_q_focus_abs,
		.t_vcm_slew = ad5816g_t_vcm_slew,
		.t_vcm_timing = ad5816g_t_vcm_timing,
	},
	[IMX135_VICTORIABAY] = {
		.power_up = dw9719_vcm_power_up,
		.power_down = dw9719_vcm_power_down,
		.init = dw9719_vcm_init,
		.t_focus_vcm = dw9719_t_focus_vcm,
		.t_focus_abs = dw9719_t_focus_abs,
		.t_focus_abs_init = NULL,
		.t_focus_rel = dw9719_t_focus_rel,
		.q_focus_status = dw9719_q_focus_status,
		.q_focus_abs = dw9719_q_focus_abs,
		.t_vcm_slew = dw9719_t_vcm_slew,
		.t_vcm_timing = dw9719_t_vcm_timing,
	},
	[IMX134_VALLEYVIEW] = {
		.power_up = dw9714_vcm_power_up,
		.power_down = dw9714_vcm_power_down,
		.init = dw9714_vcm_init,
		.t_focus_vcm = dw9714_t_focus_vcm,
		.t_focus_abs = dw9714_t_focus_abs,
		.t_focus_abs_init = dw9714_t_focus_abs_init,
		.t_focus_rel = dw9714_t_focus_rel,
		.q_focus_status = dw9714_q_focus_status,
		.q_focus_abs = dw9714_q_focus_abs,
		.t_vcm_slew = dw9714_t_vcm_slew,
		.t_vcm_timing = dw9714_t_vcm_timing,
	},
	[IMX219_MFV0_PRH] = {
		.power_up = dw9718_vcm_power_up,
		.power_down = dw9718_vcm_power_down,
		.init = dw9718_vcm_init,
		.t_focus_vcm = dw9718_t_focus_vcm,
		.t_focus_abs = dw9718_t_focus_abs,
		.t_focus_abs_init = NULL,
		.t_focus_rel = dw9718_t_focus_rel,
		.q_focus_status = dw9718_q_focus_status,
		.q_focus_abs = dw9718_q_focus_abs,
		.t_vcm_slew = dw9718_t_vcm_slew,
		.t_vcm_timing = dw9718_t_vcm_timing,
	},
	[IMX_ID_DEFAULT] = {
		.power_up = NULL,
		.power_down = NULL,
		.t_focus_abs_init = NULL,
	},
};

extern void *dummy_otp_read(struct v4l2_subdev *sd, u8 dev_addr,
	u32 start_addr, u32 size);
extern void *imx_otp_read(struct v4l2_subdev *sd, u8 dev_addr,
	u32 start_addr, u32 size);
extern void *e2prom_otp_read(struct v4l2_subdev *sd, u8 dev_addr,
	u32 start_addr, u32 size);
extern void *brcc064_otp_read(struct v4l2_subdev *sd, u8 dev_addr,
	u32 start_addr, u32 size);
extern void *imx227_otp_read(struct v4l2_subdev *sd, u8 dev_addr,
	u32 start_addr, u32 size);
extern void *e2prom_otp_read(struct v4l2_subdev *sd, u8 dev_addr,
	u32 start_addr, u32 size);
struct imx_otp imx_otps[] = {
	[IMX175_MERRFLD] = {
		.otp_read = imx_otp_read,
		.dev_addr = E2PROM_ADDR,
		.start_addr = 0,
		.size = DEFAULT_OTP_SIZE,
	},
	[IMX175_VALLEYVIEW] = {
		.otp_read = e2prom_otp_read,
		.dev_addr = E2PROM_ABICO_SS89A839_ADDR,
		.start_addr = E2PROM_2ADDR,
		.size = DEFAULT_OTP_SIZE,
	},
	[IMX135_SALTBAY] = {
		.otp_read = e2prom_otp_read,
		.dev_addr = E2PROM_ADDR,
		.start_addr = 0,
		.size = DEFAULT_OTP_SIZE,
	},
	[IMX135_VICTORIABAY] = {
		.otp_read = imx_otp_read,
		.size = DEFAULT_OTP_SIZE,
	},
	[IMX134_VALLEYVIEW] = {
		.otp_read = e2prom_otp_read,
		.dev_addr = E2PROM_LITEON_12P1BA869D_ADDR,
		.start_addr = 0,
		.size = E2PROM_LITEON_12P1BA869D_SIZE,
	},
	[IMX132_SALTBAY] = {
		.otp_read = dummy_otp_read,
		.size = DEFAULT_OTP_SIZE,
	},
	[IMX208_MOFD_PD2] = {
		.otp_read = dummy_otp_read,
		.size = DEFAULT_OTP_SIZE,
	},
	[IMX219_MFV0_PRH] = {
		.otp_read = brcc064_otp_read,
		.dev_addr = E2PROM_ADDR,
		.start_addr = 0,
		.size = IMX219_OTP_SIZE,
	},
	[IMX227_SAND] = {
		.otp_read = imx227_otp_read,
		.size = IMX227_OTP_SIZE,
	},
	[IMX_ID_DEFAULT] = {
		.otp_read = dummy_otp_read,
		.size = DEFAULT_OTP_SIZE,
	},
};

#endif

Privacy Policy