summaryrefslogtreecommitdiffstats
path: root/meta-moblin/packages/linux/linux-moblin-2.6.33.2/linux-2.6.35-moorestown-camera-driver-10.0-3-3.patch
blob: cd4edb92172c6d2db64ad49e125127b7817c3aee (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
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
From 0d55b08388f12c7c22cae9c6c745995d051624ba Mon Sep 17 00:00:00 2001
From: Zheng Ba <zheng.ba@intel.com>
Date: Thu, 1 Apr 2010 16:29:43 +0800
Subject: [PATCH 3/3] Moorestown Camera Imaging driver Beta 10.0

Patch-mainline: 2.6.35?

Changes from Beta 9.0:
1. Fixed hsd sighting:
	3469638 3469639 3469710 3469822 (high)
	3469697 (medium)

Changes from Beta 8.0:
1. Fixed hsd sighting
	3469056 3469058 (critical)
	3469705 3469696 3469709 3469510 (medium)

Changes from Beta 7.0:
1. Fixed hsd sighting 3469681,3469682,3469683 (high)

Changes from Beta 6.0:
1. Fixed hsd sighting 3469668 (high)
2. Fixed ov5630 v4l2 view-finding dark issue
3. Enabled support for popular v4l2 applications (cheese, skype, ffmpeg)

Changes from Beta 5.1:
1. Fixed CRITICAL sighting 3469558 -- ciapp fails to launch with segment fault
2. Fixed HIGH sighting 3479513 -- ov5630 AWB unstable
3. Improved KMOT sensor 720p fps from 30 to 40

Changes from Beta 5.0:
Fixed a critical issue of camera driver not loading -- hsd 3469557

Main changes from Beta 4.0:
Fixed 4 HSD sightings: 3469392,3469099,3469470,3469500

Main changes from Beta 3.0:
Fixed 7 HSD sightings: 3469264,3469112,3469395,3469103,3469105,3469471,3469484

Main changes from Beta 2.0:
Fixed 6 HSD sightings: 3469047,3469315,3469317,3469101,3468409,3469391

Main changes from Beta 1.1:
1. Added interrupt mode for jpeg capture and KMOT viewfinding
2. Fixed HSD sighting 3469228 and 3469147

Main changes from Alpha2:
Enabled MIPI interface in ISP driver and KMOT sensor s5k4e1.
Enabled FIFO in ISP driver, which doubled the fps in view-finding mode.
Enabled Subdev Framework in CI kernel driver.
Enabled AF Continuous Mode.
Enabled AE scene evaluation.

Enabled the camera drivers in kernel:
Device Drivers --> Multimedia support --> Video For Linux
Device Drivers --> Mulitmedia support --> Video capture adapters -->
--> Moorestown Langwell Camera Imaging Subsystem support.

Kernel configs:
1. camera driver depends on GPIO library and I2C driver.
CONFIG_GENERIC_GPIO=y
CONFIG_I2C=y
CONFIG_GPIOLIB=y
2. camera driver depends on videobuf-core and videobuf-dma-contig.
VIDEOBUF_GEN=y
VIDEOBUF_DMA_CONTIG=y
3. enable multimedia support and video capture.
CONFIG_MEDIA_SUPPORT=y
CONFIG_VIDEO_DEV=y
CONFIG_VIDEO_V4L2_COMMON=y
CONFIG_VIDEO_MEDIA=y
CONFIG_VIDEO_V4L2=y
4. camera drivers incluing ISP, 5630, 5630-motor, s5k4e1, s5k4e1-motor, 2650,
9665, flash.
CONFIG_VIDEO_MRSTCI=y
CONFIG_VIDEO_MRST_ISP=y
CONFIG_VIDEO_MRST_OV5630=y
CONFIG_VIDEO_MRST_OV5630_MOTOR=y
CONFIG_VIDEO_MRST_S5K4E1=y
CONFIG_VIDEO_MRST_S5K4E1_MOTOR=y
CONFIG_VIDEO_MRST_FLASH=y
CONFIG_VIDEO_MRST_OV2650=y
CONFIG_VIDEO_MRST_OV9665=y
Signed-off-by: Zheng Ba <zheng.ba@intel.com>
---
 drivers/media/video/mrstci/mrstflash/Kconfig       |    9 +
 drivers/media/video/mrstci/mrstflash/Makefile      |    3 +
 drivers/media/video/mrstci/mrstflash/mrstflash.c   |  150 +++
 drivers/media/video/mrstci/mrstov2650/Kconfig      |    9 +
 drivers/media/video/mrstci/mrstov2650/Makefile     |    3 +
 drivers/media/video/mrstci/mrstov2650/mrstov2650.c | 1190 ++++++++++++++++++++
 drivers/media/video/mrstci/mrstov2650/ov2650.h     |  766 +++++++++++++
 drivers/media/video/mrstci/mrstov5630/Kconfig      |    9 +
 drivers/media/video/mrstci/mrstov5630/Makefile     |    4 +
 drivers/media/video/mrstci/mrstov5630/ov5630.c     | 1153 +++++++++++++++++++
 drivers/media/video/mrstci/mrstov5630/ov5630.h     |  672 +++++++++++
 .../media/video/mrstci/mrstov5630_motor/Kconfig    |    9 +
 .../media/video/mrstci/mrstov5630_motor/Makefile   |    3 +
 .../mrstci/mrstov5630_motor/mrstov5630_motor.c     |  428 +++++++
 .../video/mrstci/mrstov5630_motor/ov5630_motor.h   |   86 ++
 drivers/media/video/mrstci/mrstov9665/Kconfig      |    9 +
 drivers/media/video/mrstci/mrstov9665/Makefile     |    3 +
 drivers/media/video/mrstci/mrstov9665/mrstov9665.c |  972 ++++++++++++++++
 drivers/media/video/mrstci/mrstov9665/ov9665.h     |  263 +++++
 drivers/media/video/mrstci/mrsts5k4e1/Kconfig      |    9 +
 drivers/media/video/mrstci/mrsts5k4e1/Makefile     |    3 +
 drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.c | 1024 +++++++++++++++++
 drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.h |  662 +++++++++++
 .../media/video/mrstci/mrsts5k4e1_motor/Kconfig    |    9 +
 .../media/video/mrstci/mrsts5k4e1_motor/Makefile   |    3 +
 .../mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.c     |  430 +++++++
 .../mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.h     |  102 ++
 27 files changed, 7983 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/mrstci/mrstflash/Kconfig
 create mode 100644 drivers/media/video/mrstci/mrstflash/Makefile
 create mode 100644 drivers/media/video/mrstci/mrstflash/mrstflash.c
 create mode 100644 drivers/media/video/mrstci/mrstov2650/Kconfig
 create mode 100644 drivers/media/video/mrstci/mrstov2650/Makefile
 create mode 100644 drivers/media/video/mrstci/mrstov2650/mrstov2650.c
 create mode 100644 drivers/media/video/mrstci/mrstov2650/ov2650.h
 create mode 100644 drivers/media/video/mrstci/mrstov5630/Kconfig
 create mode 100644 drivers/media/video/mrstci/mrstov5630/Makefile
 create mode 100644 drivers/media/video/mrstci/mrstov5630/ov5630.c
 create mode 100644 drivers/media/video/mrstci/mrstov5630/ov5630.h
 create mode 100644 drivers/media/video/mrstci/mrstov5630_motor/Kconfig
 create mode 100644 drivers/media/video/mrstci/mrstov5630_motor/Makefile
 create mode 100644 drivers/media/video/mrstci/mrstov5630_motor/mrstov5630_motor.c
 create mode 100644 drivers/media/video/mrstci/mrstov5630_motor/ov5630_motor.h
 create mode 100644 drivers/media/video/mrstci/mrstov9665/Kconfig
 create mode 100644 drivers/media/video/mrstci/mrstov9665/Makefile
 create mode 100644 drivers/media/video/mrstci/mrstov9665/mrstov9665.c
 create mode 100644 drivers/media/video/mrstci/mrstov9665/ov9665.h
 create mode 100755 drivers/media/video/mrstci/mrsts5k4e1/Kconfig
 create mode 100644 drivers/media/video/mrstci/mrsts5k4e1/Makefile
 create mode 100755 drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.c
 create mode 100755 drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.h
 create mode 100755 drivers/media/video/mrstci/mrsts5k4e1_motor/Kconfig
 create mode 100644 drivers/media/video/mrstci/mrsts5k4e1_motor/Makefile
 create mode 100644 drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.c
 create mode 100644 drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.h

diff --git a/drivers/media/video/mrstci/mrstflash/Kconfig b/drivers/media/video/mrstci/mrstflash/Kconfig
new file mode 100644
index 0000000..72099c5
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstflash/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_MRST_FLASH
+	tristate "Moorestown flash"
+	depends on I2C && VIDEO_MRST_ISP
+
+	---help---
+	  Say Y here if your platform support moorestown flash.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mrstov2650.ko.
diff --git a/drivers/media/video/mrstci/mrstflash/Makefile b/drivers/media/video/mrstci/mrstflash/Makefile
new file mode 100644
index 0000000..068f638
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstflash/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_MRST_FLASH)	 += mrstflash.o
+
+EXTRA_CFLAGS	+=	-I$(src)/../include
diff --git a/drivers/media/video/mrstci/mrstflash/mrstflash.c b/drivers/media/video/mrstci/mrstflash/mrstflash.c
new file mode 100644
index 0000000..5611e6b
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstflash/mrstflash.c
@@ -0,0 +1,150 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging camera flash.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
+
+static int debug;
+module_param(debug, bool, 0644);
+MODULE_PARM_DESC(debug, "Debug level (0-1)");
+
+MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
+MODULE_DESCRIPTION("A low-level driver for mrst flash");
+MODULE_LICENSE("GPL");
+
+static int flash_g_chip_ident(struct v4l2_subdev *sd,
+		struct v4l2_dbg_chip_ident *chip)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+#define V4L2_IDENT_MRST_FLASH 8248
+	return v4l2_chip_ident_i2c_client(client, chip,
+					  V4L2_IDENT_MRST_FLASH, 0);
+}
+
+static const struct v4l2_subdev_core_ops flash_core_ops = {
+	.g_chip_ident = flash_g_chip_ident,
+};
+static const struct v4l2_subdev_ops flash_ops = {
+	.core = &flash_core_ops,
+};
+
+static int flash_detect(struct i2c_client *client)
+{
+	struct i2c_adapter *adapter = client->adapter;
+	u8 pid;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		return -ENODEV;
+
+	if (adapter->nr != 0)
+		return -ENODEV;
+
+	pid = i2c_smbus_read_byte_data(client, 0x10);
+	if (pid == 0x18) {
+		printk(KERN_ERR "camera flash device found\n");
+		v4l_dbg(1, debug, client, "found camera flash device");
+	} else {
+		printk(KERN_ERR "no camera flash device found\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int flash_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	u8 pid, ver;
+	int ret = -1;
+	struct v4l2_subdev *sd;
+
+	v4l_info(client, "chip found @ 0x%x (%s)\n",
+			client->addr << 1, client->adapter->name);
+
+	sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+	ret = flash_detect(client);
+	if (ret)
+		return -ENODEV;
+
+	v4l2_i2c_subdev_init(sd, client, &flash_ops);
+
+	ver = i2c_smbus_read_byte_data(client, 0x50);
+	v4l_dbg(1, debug, client, "detect:CST from device is 0x%x", ver);
+	pid = i2c_smbus_read_byte_data(client, 0x20);
+	v4l_dbg(1, debug, client, "detect:MFPC from device is 0x%x", pid);
+	pid = i2c_smbus_read_byte_data(client, 0xA0);
+	v4l_dbg(1, debug, client, "detect:TCC from device is 0x%x", pid);
+	pid = i2c_smbus_read_byte_data(client, 0xB0);
+	v4l_dbg(1, debug, client, "detect:FCC from device is 0x%x", pid);
+	pid = i2c_smbus_read_byte_data(client, 0xC0);
+	v4l_dbg(1, debug, client, "detect:FDC from device is 0x%x", pid);
+	i2c_smbus_write_byte_data(client, 0xc0, 0xff); /*set FST to 1000us*/
+	pid = i2c_smbus_read_byte_data(client, 0xc0);
+	v4l_dbg(1, debug, client, "FDC from device is 0x%x", pid);
+
+	v4l_dbg(1, debug, client,
+		"successfully load camera flash device driver");
+	return 0;
+}
+
+static int flash_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+	v4l2_device_unregister_subdev(sd);
+
+	return 0;
+}
+
+static const struct i2c_device_id flash_id[] = {
+	{"mrst_camera_flash", 0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, flash_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = "mrst_camera_flash",
+	.probe = flash_probe,
+	.remove = flash_remove,
+	.id_table = flash_id,
+};
diff --git a/drivers/media/video/mrstci/mrstov2650/Kconfig b/drivers/media/video/mrstci/mrstov2650/Kconfig
new file mode 100644
index 0000000..d39d894
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov2650/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_MRST_OV2650
+	tristate "Moorestown OV2650 SoC Sensor"
+	depends on I2C && VIDEO_MRST_ISP
+
+	---help---
+	  Say Y here if your platform support OV2650 SoC Sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mrstov2650.ko.
diff --git a/drivers/media/video/mrstci/mrstov2650/Makefile b/drivers/media/video/mrstci/mrstov2650/Makefile
new file mode 100644
index 0000000..fb16d57
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov2650/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_MRST_OV2650)	 += mrstov2650.o
+
+EXTRA_CFLAGS	+=	-I$(src)/../include
\ No newline at end of file
diff --git a/drivers/media/video/mrstci/mrstov2650/mrstov2650.c b/drivers/media/video/mrstci/mrstov2650/mrstov2650.c
new file mode 100644
index 0000000..7f0d478
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov2650/mrstov2650.c
@@ -0,0 +1,1190 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <linux/videodev2.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
+
+#include "ci_sensor_common.h"
+#include "ov2650.h"
+
+static int mrstov2650_debug;
+module_param(mrstov2650_debug, int, 0644);
+MODULE_PARM_DESC(mrstov2650_debug, "Debug level (0-1)");
+
+#define dprintk(level, fmt, arg...) do {			\
+	if (mrstov2650_debug >= level) 					\
+		printk(KERN_DEBUG "mrstisp@%s: " fmt "\n", \
+		       __func__, ## arg); } \
+	while (0)
+
+#define eprintk(fmt, arg...)	\
+	printk(KERN_ERR "mrstisp@%s: line %d: " fmt "\n",	\
+	       __func__, __LINE__, ## arg);
+
+#define DBG_entering	dprintk(2, "entering");
+#define DBG_leaving	dprintk(2, "leaving");
+#define DBG_line	dprintk(2, " line: %d", __LINE__);
+
+static inline struct ci_sensor_config *to_sensor_config(struct v4l2_subdev *sd)
+{
+	return container_of(sd, struct ci_sensor_config, sd);
+}
+
+static struct ov2650_format_struct {
+	__u8 *desc;
+	__u32 pixelformat;
+	struct regval_list *regs;
+} ov2650_formats[] = {
+	{
+		.desc		= "YUYV 4:2:2",
+		.pixelformat	= SENSOR_MODE_BT601,
+		.regs 		= NULL,
+	},
+};
+#define N_OV2650_FMTS ARRAY_SIZE(ov2650_formats)
+
+static struct ov2650_res_struct {
+	__u8 *desc;
+	int res;
+	int width;
+	int height;
+	/* FIXME: correct the fps values.. */
+	int fps;
+	bool used;
+	struct regval_list *regs;
+} ov2650_res[] = {
+	{
+		.desc		= "UXGA",
+		.res		= SENSOR_RES_UXGA,
+		.width		= 1600,
+		.height		= 1200,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov2650_res_uxga,
+	},
+	{
+		.desc		= "SXGA",
+		.res		= SENSOR_RES_SXGA,
+		.width		= 1280,
+		.height		= 1024,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov2650_res_sxga,
+	},
+	{
+		.desc 		= "SVGA",
+		.res		= SENSOR_RES_SVGA,
+		.width		= 800,
+		.height		= 600,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov2650_res_svga,
+	},
+	{
+		.desc		= "VGA",
+		.res		= SENSOR_RES_VGA,
+		.width		= 640,
+		.height		= 480,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov2650_res_vga_vario,
+	},
+	{
+		.desc 		= "QVGA",
+		.res		= SENSOR_RES_QVGA,
+		.width		= 320,
+		.height		= 240,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov2650_res_qvga,
+	},
+};
+
+#define N_RES (ARRAY_SIZE(ov2650_res))
+
+/*
+ * I2C Read & Write stuff
+ */
+static int ov2650_read(struct i2c_client *c, u16 reg, u8 *value)
+{
+	int ret;
+	int i;
+	struct i2c_msg msg[2];
+	u8 msgbuf[2];
+	u8 ret_val = 0;
+	*value = 0;
+	/* Read needs two message to go */
+	memset(&msg, 0, sizeof(msg));
+	msgbuf[0] = 0;
+	msgbuf[1] = 0;
+	i = 0;
+	msgbuf[i++] = reg >> 8;
+	msgbuf[i++] = reg;
+	msg[0].addr = c->addr;
+	msg[0].buf = msgbuf;
+	msg[0].len = i;
+
+	msg[1].addr = c->addr;
+	msg[1].flags = I2C_M_RD;
+	msg[1].buf = &ret_val;
+	msg[1].len = 1;
+
+	ret = i2c_transfer(c->adapter, &msg[0], 2);
+	*value = ret_val;
+
+	ret = (ret == 2) ? 0 : -1;
+	return ret;
+}
+
+static int ov2650_write(struct i2c_client *c, u16 reg, u8 value)
+{
+	int ret, i;
+	struct i2c_msg msg;
+	u8 msgbuf[3];
+
+	/* Writing only needs one message */
+	memset(&msg, 0, sizeof(msg));
+	i = 0;
+	msgbuf[i++] = reg >> 8;
+	msgbuf[i++] = reg;
+	msgbuf[i++] = value;
+
+	msg.addr = c->addr;
+	msg.flags = 0;
+	msg.buf = msgbuf;
+	msg.len = i;
+
+	ret = i2c_transfer(c->adapter, &msg, 1);
+
+	/* If this is a reset register, wait for 1ms */
+	if (reg == OV2650_SYS && (value & 0x80))
+		msleep(3);
+
+	ret = (ret == 1) ? 0 : -1;
+	return ret;
+}
+
+static int ov2650_write_array(struct i2c_client *c, struct regval_list *vals)
+{
+	struct regval_list *p;
+	u8 read_val = 0;
+	int err_num = 0;
+	int i = 0;
+	p = vals;
+	while (p->reg_num != 0xffff) {
+		ov2650_write(c, p->reg_num, p->value);
+		ov2650_read(c, p->reg_num, &read_val);
+		if (read_val != p->value)
+			err_num++;
+		p++;
+		i++;
+	}
+	return 0;
+}
+
+static int ov2650_set_data_pin_in(struct i2c_client *client)
+{
+	int ret = 0;
+	u8 reg;
+
+	ret += ov2650_write(client, 0x30b0, 0x00);
+
+	ret += ov2650_read(client, 0x30b1, &reg);
+	reg &= 0xfc;
+	ret += ov2650_write(client, 0x30b1, reg);
+
+	return ret;
+}
+
+static int ov2650_set_data_pin_out(struct i2c_client *client)
+{
+	int ret = 0;
+	u8 reg;
+
+	ret += ov2650_write(client, 0x30b0, 0xff);
+
+	ret += ov2650_read(client, 0x30b1, &reg);
+	reg &= 0xfc;
+	reg |= 0x03;
+	ret += ov2650_write(client, 0x30b1, reg);
+
+	return ret;
+}
+/*
+ * Sensor specific helper function
+ */
+static int ov2650_standby(void)
+{
+	gpio_set_value(GPIO_STDBY_PIN, 1);
+	dprintk(1, "PM: standby called\n");
+	return 0;
+}
+
+static int ov2650_wakeup(void)
+{
+	gpio_set_value(GPIO_STDBY_PIN, 0);
+	dprintk(1, "PM: wakeup called\n");
+	return 0;
+}
+
+static int ov2650_s_power(struct v4l2_subdev *sd, u32 val)
+{
+	if (val == 1)
+		ov2650_standby();
+	if (val == 0)
+		ov2650_wakeup();
+	return 0;
+}
+
+static int ov2650_init(struct i2c_client *c)
+{
+	int ret;
+	struct v4l2_subdev *sd = i2c_get_clientdata(c);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+
+	/* Fill the configuration structure */
+	/* Note this default configuration value */
+	info->mode = ov2650_formats[0].pixelformat;
+	info->res = ov2650_res[0].res;
+	info->type = SENSOR_TYPE_SOC;
+	info->bls = SENSOR_BLS_OFF;
+	info->gamma = SENSOR_GAMMA_ON;
+	info->cconv = SENSOR_CCONV_ON;
+	info->blc = SENSOR_BLC_AUTO;
+	info->agc = SENSOR_AGC_AUTO;
+	info->awb = SENSOR_AWB_AUTO;
+	info->aec = SENSOR_AEC_AUTO;
+	info->bus_width = SENSOR_BUSWIDTH_8BIT_ZZ;
+	info->ycseq = SENSOR_YCSEQ_YCBYCR;
+	info->conv422 = SENSOR_CONV422_COSITED;
+	info->bpat = SENSOR_BPAT_BGBGGRGR;/* GRGRBGBG; */
+	info->field_inv = SENSOR_FIELDINV_NOSWAP;
+	info->field_sel = SENSOR_FIELDSEL_BOTH;
+	info->hpol = SENSOR_HPOL_REFPOS;
+	info->vpol = SENSOR_VPOL_POS;
+	info->edge = SENSOR_EDGE_RISING;
+	info->flicker_freq = SENSOR_FLICKER_100;
+	info->cie_profile = 0;
+	memcpy(info->name, "ov2650", 7);
+
+	ret = ov2650_write(c, OV2650_SYS, 0x80);
+	/* Set registers into default config value */
+	ret += ov2650_write_array(c, ov2650_def_reg);
+
+	/* added by wen to stop sensor from streaming */
+	ov2650_write(c, 0x3086, 0x0f);
+	ov2650_set_data_pin_in(c);
+	ssleep(1);
+
+	return ret;
+}
+
+static int distance(struct ov2650_res_struct *res, u32 w, u32 h)
+{
+	int ret;
+	if (res->width < w || res->height < h)
+		return -1;
+
+	ret = ((res->width - w) + (res->height - h));
+	return ret;
+}
+
+static int ov2650_try_res(u32 *w, u32 *h)
+{
+	struct ov2650_res_struct *res_index, *p = NULL;
+	int dis, last_dis = ov2650_res->width + ov2650_res->height;
+
+	dprintk(1, "&&&&&  before %dx%d", *w, *h);
+	for (res_index = ov2650_res;
+	     res_index < ov2650_res + N_RES;
+	     res_index++) {
+		if ((res_index->width <= *w) && (res_index->height <= *h))
+			break;
+		dis = distance(res_index, *w, *h);
+		if (dis < last_dis) {
+			last_dis = dis;
+			p = res_index;
+		}
+	}
+	if ((res_index->width < *w) || (res_index->height < *h)) {
+		if (res_index != ov2650_res)
+			res_index--;
+	}
+
+	/*
+	if (p == NULL) {
+		p = ov2650_res;
+	}
+
+	if ((w != NULL) && (h != NULL)) {
+		*w = p->width;
+		*h = p->height;
+	}
+	*/
+	if (res_index == ov2650_res + N_RES)
+		res_index = ov2650_res + N_RES - 1;
+
+	*w = res_index->width;
+	*h = res_index->height;
+
+	dprintk(1, "&&&&&  after %dx%d", *w, *h);
+	return 0;
+}
+
+static struct ov2650_res_struct *ov2650_to_res(u32 w, u32 h)
+{
+	struct ov2650_res_struct *res_index;
+
+	for (res_index = ov2650_res;
+	     res_index < ov2650_res + N_RES;
+	     res_index++)
+		if ((res_index->width == w) && (res_index->height == h))
+			break;
+
+	if (res_index >= ov2650_res + N_RES)
+		res_index--;   /* Take the bigger one */
+
+	return res_index;
+}
+
+static int ov2650_try_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	DBG_entering;
+	dprintk(1, "&&&&&  before %dx%d", fmt->fmt.pix.width,
+		fmt->fmt.pix.height);
+	return ov2650_try_res(&fmt->fmt.pix.width, &fmt->fmt.pix.height);
+	dprintk(1, "&&&&&  after %dx%d", fmt->fmt.pix.width,
+		fmt->fmt.pix.height);
+	DBG_leaving;
+}
+
+static int ov2650_get_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	unsigned short width, height;
+	int index;
+
+	ci_sensor_res2size(info->res, &width, &height);
+
+	/* Marked the current sensor res as being "used" */
+	for (index = 0; index < N_RES; index++) {
+		if ((width == ov2650_res[index].width) &&
+		    (height == ov2650_res[index].height)) {
+			ov2650_res[index].used = 1;
+			continue;
+		}
+		ov2650_res[index].used = 0;
+	}
+
+	fmt->fmt.pix.width = width;
+	fmt->fmt.pix.height = height;
+	return 0;
+}
+
+static int ov2650_set_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	int ret = 0;
+	struct ov2650_res_struct *res_index;
+	u32 width, height;
+	int index;
+
+	DBG_entering;
+
+	width = fmt->fmt.pix.width;
+	height = fmt->fmt.pix.height;
+
+	ret = ov2650_try_res(&width, &height);
+	res_index = ov2650_to_res(width, height);
+
+	ov2650_wakeup();
+
+	/* if ((info->res != res_index->res) && (res_index->regs)) { */
+	if (res_index->regs) {
+
+		dprintk(2, "changing res from to %dx%d", width, height);
+		ret = ov2650_write(client, OV2650_SYS, 0x80);
+		ret += ov2650_write_array(client, ov2650_def_reg);
+		ret += ov2650_write_array(client, res_index->regs);
+
+		/* add to debug
+		if(res_index->res == SENSOR_RES_VGA) {
+			ret += ov2650_write_array(c, ov2650_def_reg);
+			ret += ov2650_write_array(c, res_index->regs);
+		} else {
+			ret += ov2650_write_array(c, ov2650_res_vga_reverse);
+			ret += ov2650_write_array(c, res_index->regs);
+		}
+		*/
+
+		/* Add delay here to get better image */
+		/*
+		if (res_index->res == SENSOR_RES_SXGA ||
+		   res_index->res == SENSOR_RES_UXGA)
+			msleep(2000);
+		else
+			msleep(900);
+			*/
+
+		/* Marked current sensor res as being "used" */
+		for (index = 0; index < N_RES; index++) {
+			if ((width == ov2650_res[index].width) &&
+			    (height == ov2650_res[index].height)) {
+				ov2650_res[index].used = 1;
+				continue;
+			}
+			ov2650_res[index].used = 0;
+		}
+
+		for (index = 0; index < N_RES; index++)
+			dprintk(2, "index = %d, used = %d\n", index,
+				ov2650_res[index].used);
+
+	}
+
+	info->res = res_index->res;
+
+	/*
+	int i;
+	unsigned char value;
+	printk(KERN_WARNING "2650 reg dumping start:\n");
+	for(i = 0x3000; i <= 0x360B; i ++) {
+		ov2650_read(c, i, &value);
+		printk(KERN_WARNING "reg at offset %4x = %x\n", i, value);
+	}
+	printk(KERN_WARNING "2650 reg dumping finished:\n");
+	*/
+
+	DBG_leaving;
+
+	return ret;
+}
+
+static int ov2650_q_hflip(struct v4l2_subdev *sd, __s32 *value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	int err;
+	unsigned char v;
+
+	err = ov2650_read(client, OV2650_TMC_6, &v);
+	*value = (v & 0x02) == 0x02;
+	return err;
+}
+
+static int ov2650_t_hflip(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	unsigned char v, v1 = 0;
+	int err;
+
+	value = value >= 1 ? 1 : 0;
+	err = ov2650_read(client, OV2650_TMC_6, &v);
+	if (value) {
+		v |= 0x02;
+		v1 |= 0x08;
+		info->bpat = SENSOR_BPAT_GRGRBGBG;/*BGBGGRGR;*/
+	} else {
+		v &= ~0x02;
+		v1 &= ~0x08;
+		info->bpat = SENSOR_BPAT_BGBGGRGR;
+	}
+	err += ov2650_write(client, OV2650_TMC_6, v);
+	err += ov2650_write(client, 0x3090, v1);
+	msleep(10);  /* FIXME */
+
+	return err;
+}
+
+static int ov2650_q_vflip(struct v4l2_subdev *sd, __s32 *value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	int err;
+	unsigned char v;
+
+	err = ov2650_read(client, OV2650_TMC_6, &v);
+	*value = (v & 0x01) == 0x01;
+	return err;
+}
+
+
+static int ov2650_t_vflip(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	int err = 0;
+	unsigned char v;
+
+	value = value >= 1 ? 1 : 0;
+	err = ov2650_read(client, OV2650_TMC_6, &v);
+	if (value)
+		v |= 0x01;
+	else
+		v &= ~0x01;
+	err += ov2650_write(client, OV2650_TMC_6, v);
+	msleep(10);  /* FIXME */
+
+	return err;
+}
+
+#if 0
+static int ov2650_t_awb(struct i2c_client *c, int value)
+{
+	unsigned char v;
+	int ret;
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+
+	value = value >= 1 ? 1 : 0;
+	ret = ov2650_read(c, OV2650_ISP_CTL_0, &v);
+	if (value & 0x01) {
+		v |= 0x30;
+		info->awb = SENSOR_AWB_AUTO;
+	} else {
+		v &= ~0x30;
+		info->awb = SENSOR_AWB_OFF;
+	}
+	ret += ov2650_write(c, OV2650_ISP_CTL_0, v);
+	msleep(10);  /* FIXME */
+
+	return ret;
+}
+
+static int ov2650_q_awb(struct i2c_client *c, int *value)
+{
+	int ret;
+	unsigned char v;
+
+	ret = ov2650_read(c, OV2650_ISP_CTL_0, &v);
+	*value = (v & 0x30) == 0x30;
+	return ret;
+}
+
+static int ov2650_t_agc(struct i2c_client *c, int value)
+{
+	unsigned char v;
+	int ret;
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+
+	value = value >= 1 ? 1 : 0;
+	ret = ov2650_read(c, OV2650_ISP_CTL_0, &v);
+	if (value & 0x01) {
+		v |= 0x10;
+		info->agc = SENSOR_AGC_AUTO;
+	} else {
+		v &= ~0x10;
+		info->agc = SENSOR_AGC_OFF;
+	}
+	ret += ov2650_write(c, OV2650_ISP_CTL_0, v);
+	msleep(10);  /* FIXME */
+
+	return ret;
+}
+
+static int ov2650_q_agc(struct i2c_client *c, int *value)
+{
+	int ret;
+	unsigned char v;
+
+	ret = ov2650_read(c, OV2650_ISP_CTL_0, &v);
+	*value = (v & 0x10) == 0x10;
+	return ret;
+}
+
+static int ov2650_t_blc(struct i2c_client *c, int value)
+{
+	unsigned char v;
+	int ret;
+
+	value = value >= 1 ? 1 : 0;
+
+	ret = ov2650_read(c, OV2650_BLCC, &v);
+	if (value & 0x01)
+		v |= 0x10;
+	else
+		v &= ~0x10;
+	ret += ov2650_write(c, OV2650_BLCC, v);
+	msleep(10);  /* FIXME */
+
+	return ret;
+}
+
+static int ov2650_q_blc(struct i2c_client *c, int *value)
+{
+	int ret;
+	unsigned char v;
+
+	ret = ov2650_read(c, OV2650_BLCC, &v);
+	*value = (v & 0x10) == 0x10;
+	return ret;
+}
+#endif
+
+static struct ov2650_control {
+	struct v4l2_queryctrl qc;
+	int (*query)(struct v4l2_subdev *sd, __s32 *value);
+	int (*tweak)(struct v4l2_subdev *sd, int value);
+} ov2650_controls[] = {
+	{
+		.qc = {
+			.id = V4L2_CID_VFLIP,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "Vertical flip",
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 0,
+		},
+		.tweak = ov2650_t_vflip,
+		.query = ov2650_q_vflip,
+	},
+	{
+		.qc = {
+			.id = V4L2_CID_HFLIP,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "Horizontal mirror",
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 0,
+		},
+		.tweak = ov2650_t_hflip,
+		.query = ov2650_q_hflip,
+	},
+#if 0
+	{
+		.parm = {
+			.index = V4L2_CID_AUTO_WHITE_BALANCE,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "Auto White Balance",
+			.min = 0,
+			.max = 1,
+			.step = 1,
+			.def_value = 1,
+		},
+		.tweak = ov2650_t_awb,
+		.query = ov2650_q_awb,
+	},
+	{
+		.parm = {
+			.index = V4L2_CID_AUTOGAIN,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "Auto Gain Control",
+			.min = 0,
+			.max = 1,
+			.step = 1,
+			.def_value = 1,
+		},
+		.tweak = ov2650_t_agc,
+		.query = ov2650_q_agc,
+
+	},
+	{
+		.parm = {
+			.index = V4L2_CID_BLACK_LEVEL,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "Black Level Control",
+			.min = 0,
+			.max = 1,
+			.step = 1,
+			.def_value = 1,
+		},
+		.tweak = ov2650_t_blc,
+		.query = ov2650_q_blc,
+
+	},
+#endif
+};
+#define N_CONTROLS (ARRAY_SIZE(ov2650_controls))
+
+static struct ov2650_control *ov2650_find_control(__u32 id)
+{
+	int i;
+
+	for (i = 0; i < N_CONTROLS; i++)
+		if (ov2650_controls[i].qc.id == id)
+			return ov2650_controls + i;
+	return NULL;
+}
+
+static int ov2650_queryctrl(struct v4l2_subdev *sd,
+			    struct v4l2_queryctrl *qc)
+{
+	struct ov2650_control *octrl;
+	octrl = ov2650_find_control(qc->id);
+	if (NULL == octrl)
+		return -EINVAL;
+	*qc = octrl->qc;
+	return 0;
+}
+
+static int ov2650_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+	struct ov2650_control *octrl = ov2650_find_control(ctrl->id);
+	int ret;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret = octrl->query(sd, &ctrl->value);
+	if (ret >= 0)
+		return 0;
+	return ret;
+}
+
+static int ov2650_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+	struct ov2650_control *octrl = ov2650_find_control(ctrl->id);
+	int ret;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret =  octrl->tweak(sd, ctrl->value);
+	if (ret >= 0)
+		return 0;
+	return ret;
+}
+#if 0
+static int ov2650_get_caps(struct i2c_client *c, struct ci_sensor_caps *caps)
+{
+	if (caps == NULL)
+		return -EIO;
+
+	caps->bus_width = SENSOR_BUSWIDTH_8BIT_ZZ;
+	caps->mode	= SENSOR_MODE_BT601;
+	caps->field_inv = SENSOR_FIELDINV_NOSWAP;
+	caps->field_sel = SENSOR_FIELDSEL_BOTH;
+	caps->ycseq	= SENSOR_YCSEQ_YCBYCR;
+	caps->conv422	= SENSOR_CONV422_COSITED;
+	caps->bpat	= SENSOR_BPAT_BGBGGRGR;
+	caps->hpol	= SENSOR_HPOL_REFPOS;
+	caps->vpol	= SENSOR_VPOL_POS;
+	caps->edge	= SENSOR_EDGE_RISING;
+	caps->bls	= SENSOR_BLS_OFF;
+	caps->gamma	= SENSOR_GAMMA_ON;
+	caps->cconv	= SENSOR_CCONV_ON;
+	caps->res	= SENSOR_RES_UXGA | SENSOR_RES_SXGA | SENSOR_RES_SVGA
+	    | SENSOR_RES_VGA | SENSOR_RES_QVGA;
+	caps->blc	= SENSOR_BLC_AUTO;
+	caps->agc	= SENSOR_AGC_AUTO;
+	caps->awb	= SENSOR_AWB_AUTO;
+	caps->aec	= SENSOR_AEC_AUTO;
+	caps->cie_profile	= 0;
+	caps->flicker_freq	= SENSOR_FLICKER_100 | SENSOR_FLICKER_120;
+	caps->type	= SENSOR_TYPE_SOC;
+	/* caps->name	= "ov2650"; */
+	strcpy(caps->name, "ov2650");
+
+	return 0;
+}
+
+static int ov2650_get_config(struct i2c_client *c,
+			     struct ci_sensor_config *config)
+{
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+
+	if (config == NULL) {
+		printk(KERN_WARNING "sensor_get_config: NULL pointer\n");
+		return -EIO;
+	}
+
+	memcpy(config, info, sizeof(struct ci_sensor_config));
+
+	return 0;
+}
+
+static int ov2650_setup(struct i2c_client *c,
+			const struct ci_sensor_config *config)
+{
+	int ret;
+	struct ov2650_res_struct *res_index;
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+	u16 width, high;
+
+	/* Soft reset camera first*/
+	ret = ov2650_write(c, OV2650_SYS, 0x80);
+
+	/* Set registers into default config value */
+	ret += ov2650_write_array(c, ov2650_def_reg);
+
+	/* set image resolution */
+	ci_sensor_res2size(config->res, &width, &high);
+	ret += ov2650_try_res(c, &width, &high);
+	res_index = ov2650_find_res(width, high);
+	if (res_index->regs)
+		ret += ov2650_write_array(c, res_index->regs);
+	if (!ret)
+		info->res = res_index->res;
+
+
+	if (config->blc != info->blc) {
+		ret += ov2650_t_blc(c, config->blc);
+		info->blc = config->blc;
+	}
+
+	if (config->agc != info->agc) {
+		ret += ov2650_t_agc(c, config->agc);
+		info->agc = config->agc;
+	}
+
+	if (config->awb != info->awb) {
+		ret += ov2650_t_awb(c, config->awb);
+		info->awb = config->awb;
+	}
+	/* Add some delay here to get a better image*/
+	if (res_index->res == SENSOR_RES_SXGA ||
+	    res_index->res == SENSOR_RES_UXGA)
+		msleep(2000);
+	else
+		msleep(900);
+
+	return ret;
+}
+
+/*
+ * File operation functions
+ */
+
+
+
+static int ov2650_open(struct i2c_setting *c, void *priv)
+{
+	struct i2c_client *client = c->sensor_client;
+	/* Just wake up sensor */
+	if (ov2650_wakeup())
+		return -EIO;
+	ov2650_init(client);
+	/*Sleep sensor now*/
+	ov2650_write(client, 0x3086, 0x0f);
+
+	/* set data pin to input */
+	if (ov2650_set_data_pin_in(client))
+		return -EIO;
+
+	return 0;
+}
+
+static int ov2650_release(struct i2c_setting *c, void *priv)
+{
+	/* Just suspend the sensor */
+	ov2650_standby();
+	return 0;
+}
+
+static int ov2650_on(struct i2c_setting *c)
+{
+	int ret;
+
+	/* Software wake up sensor */
+	ret = ov2650_write(c->sensor_client, 0x3086, 0x00);
+
+	/* set data pin to output */
+	return ret + ov2650_set_data_pin_out(c->sensor_client);
+}
+
+static int ov2650_off(struct i2c_setting *c)
+{
+	int ret;
+
+	/* Software standby sensor */
+	ret = ov2650_write(c->sensor_client, 0x3086, 0x0f);
+
+	/* set data pin to input */
+	return ret + ov2650_set_data_pin_in(c->sensor_client);
+}
+
+static struct sensor_device ov2650 = {
+	.name	= "OV2650",
+	.type	= SENSOR_TYPE_SOC,
+	.minor	= -1,
+	.open	= ov2650_open,
+	.release = ov2650_release,
+	.on = ov2650_on,
+	.off = ov2650_off,
+	.querycap = ov2650_get_caps,
+	.get_config = ov2650_get_config,
+	.set_config = ov2650_setup,
+	.enum_parm = ov2650_queryctrl,
+	.get_parm = ov2650_g_ctrl,
+	.set_parm = ov2650_s_ctrl,
+	.try_res = ov2650_try_res,
+	.set_res = ov2650_set_res,
+	.suspend = ov2650_standby,
+	.resume = ov2650_wakeup,
+	.get_ls_corr_config = NULL,
+	.set_awb = NULL,
+	.set_aec = NULL,
+	.set_blc = NULL,
+	/* TBC */
+};
+#endif
+
+static int ov2650_s_stream(struct v4l2_subdev *sd, int enable)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	DBG_entering;
+
+
+	if (enable) {
+		ov2650_write(client, 0x3086, 0x00);
+		ov2650_set_data_pin_out(client);
+		msleep(2000);
+	} else {
+		ov2650_write(client, 0x3086, 0x0f);
+		ov2650_set_data_pin_in(client);
+	}
+
+	DBG_leaving;
+	return 0;
+}
+
+static int ov2650_enum_framesizes(struct v4l2_subdev *sd,
+				  struct v4l2_frmsizeenum *fsize)
+{
+	unsigned int index = fsize->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+	fsize->discrete.width = ov2650_res[index].width;
+	fsize->discrete.height = ov2650_res[index].height;
+	fsize->reserved[0] = ov2650_res[index].used;
+
+	DBG_leaving;
+
+	return 0;
+}
+
+static int ov2650_enum_frameintervals(struct v4l2_subdev *sd,
+				      struct v4l2_frmivalenum *fival)
+{
+	unsigned int index = fival->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+	fival->discrete.numerator = 1;
+	fival->discrete.denominator = ov2650_res[index].fps;
+
+	DBG_leaving;
+
+	return 0;
+}
+static int ov2650_g_chip_ident(struct v4l2_subdev *sd,
+		struct v4l2_dbg_chip_ident *chip)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+#define V4L2_IDENT_OV2650 8244
+	return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV2650, 0);
+}
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int ov2650_g_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	unsigned char val = 0;
+	int ret;
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	ret = ov2650_read(client, reg->reg & 0xffff, &val);
+	reg->val = val;
+	reg->size = 1;
+	return ret;
+}
+
+static int ov2650_s_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	ov2650_write(client, reg->reg & 0xffff, reg->val & 0xff);
+	return 0;
+}
+#endif
+
+static const struct v4l2_subdev_video_ops ov2650_video_ops = {
+	.try_fmt = ov2650_try_fmt,
+	.s_fmt = ov2650_set_fmt,
+	.g_fmt = ov2650_get_fmt,
+	.s_stream = ov2650_s_stream,
+	.enum_framesizes = ov2650_enum_framesizes,
+	.enum_frameintervals = ov2650_enum_frameintervals,
+};
+
+static const struct v4l2_subdev_core_ops ov2650_core_ops = {
+	.g_chip_ident = ov2650_g_chip_ident,
+	.queryctrl = ov2650_queryctrl,
+	.g_ctrl = ov2650_g_ctrl,
+	.s_ctrl = ov2650_s_ctrl,
+	.s_gpio = ov2650_s_power,
+	/*.g_ext_ctrls = ov2650_g_ext_ctrls,*/
+	/*.s_ext_ctrls = ov2650_s_ext_ctrls,*/
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+	.g_register = ov2650_g_register,
+	.s_register = ov2650_s_register,
+#endif
+};
+
+static const struct v4l2_subdev_ops ov2650_ops = {
+	.core = &ov2650_core_ops,
+	.video = &ov2650_video_ops,
+};
+
+/*
+ * Basic i2c stuff
+ */
+#if 0
+static unsigned short normal_i2c[] = {I2C_OV2650 >> 1, I2C_CLIENT_END};
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver ov2650_driver;
+#endif
+static int ov2650_detect(struct i2c_client *client)
+{
+	struct i2c_adapter *adapter = client->adapter;
+	int adap_id = i2c_adapter_id(adapter);
+	u8 value;
+
+	printk(KERN_WARNING "Now start ov2650 detect\n");
+	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
+		return -ENODEV;
+
+	if (adap_id != 1)
+		return -ENODEV;
+
+	/* if (ov2650_wakeup()) */
+		/* return -ENODEV; */
+	ov2650_wakeup();
+
+	ov2650_read(client, OV2650_PID_L, &value);
+	if (value != 0x52)
+		return -ENODEV;
+
+	return 0;
+}
+
+static int ov2650_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	struct ci_sensor_config *info;
+	struct v4l2_subdev *sd;
+	int ret = -1;
+
+	DBG_entering;
+
+	printk(KERN_INFO "Init ov2650 sensor \n");
+
+	v4l_info(client, "chip found @ 0x%x (%s)\n",
+			client->addr << 1, client->adapter->name);
+	/*
+	 * Setup sensor configuration structure
+	 */
+	info = kzalloc(sizeof(struct ci_sensor_config), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	ret = ov2650_detect(client);
+	if (ret) {
+		kfree(info);
+		return -ENODEV;
+	}
+
+	sd = &info->sd;
+	v4l2_i2c_subdev_init(sd, client, &ov2650_ops);
+
+	/*
+	 * TODO: Need to check if this can be here.
+	 * Turn into standby mode
+	 */
+	/* ov2650_standby(); */
+	ret += ov2650_init(client);
+	ov2650_standby();
+
+	printk(KERN_INFO "Init ov2650 sensor success, ret = %d\n", ret);
+
+	DBG_leaving;
+	return 0;
+}
+
+static int ov2650_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+	v4l2_device_unregister_subdev(sd);
+	kfree(to_sensor_config(sd));
+	return 0;
+}
+
+static const struct i2c_device_id ov2650_id[] = {
+	{"ov2650", 0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, ov2650_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = "ov2650",
+	.probe = ov2650_probe,
+	.remove = ov2650_remove,
+	/* .suspend = ov2650_suspend,
+	 * .resume = ov2650_resume, */
+	.id_table = ov2650_id,
+};
+
+MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
+MODULE_DESCRIPTION("A low-level driver for OmniVision 2650 sensors");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/mrstci/mrstov2650/ov2650.h b/drivers/media/video/mrstci/mrstov2650/ov2650.h
new file mode 100644
index 0000000..f5c0418
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov2650/ov2650.h
@@ -0,0 +1,766 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#define I2C_OV2650	0x60
+/* Should add to kernel source */
+#define I2C_DRIVERID_OV2650	1047
+/* GPIO pin on Moorestown */
+#define GPIO_SCLK_25	44
+#define GPIO_STB_PIN	47
+#define GPIO_STDBY_PIN	48
+#define GPIO_RESET_PIN	50
+
+/* System control register */
+#define OV2650_AGC 		0x3000
+#define OV2650_AGCS 	0x3001
+#define OV2650_AEC_H	0x3002
+#define OV2650_AEC_L  	0x3003
+#define OV2650_AECL 	0x3004
+#define OV2650_AECS_H	0x3008
+#define OV2650_AECS_L	0x3009
+#define OV2650_PID_H	0x300A
+#define OV2650_PID_L	0x300B
+#define OV2650_SCCB		0x300C
+#define OV2650_PCLK		0x300D
+#define OV2650_PLL_1	0x300E
+#define OV2650_PLL_2	0x300F
+#define OV2650_PLL_3	0x3010
+#define OV2650_CLK		0x3011
+#define OV2650_SYS		0x3012
+#define OV2650_AUTO_1	0x3013
+#define OV2650_AUTO_2	0x3014
+#define OV2650_AUTO_3	0x3015
+#define OV2650_AUTO_4	0x3016
+#define OV2650_AUTO_5	0x3017
+#define OV2650_WPT		0x3018
+#define OV2650_BPT		0x3019
+#define OV2650_VPT		0x301A
+#define OV2650_YAVG		0x301B
+#define OV2650_AECG_50	0x301C
+#define OV2650_AECG_60	0x301D
+#define OV2650_RZM_H	0x301E
+#define OV2650_RZM_L	0x301F
+#define OV2650_HS_H		0x3020
+#define OV2650_HS_L		0x3021
+#define OV2650_VS_H		0x3022
+#define OV2650_VS_L		0x3023
+#define OV2650_HW_H		0x3024
+#define OV2650_HW_L		0x3025
+#define OV2650_VH_H		0x3026
+#define OV2650_VH_L		0x3027
+#define OV2650_HTS_H	0x3028
+#define OV2650_HTS_L	0x3029
+#define OV2650_VTS_H	0x302A
+#define OV2650_VTS_L	0x302B
+#define OV2650_EXHTS	0x302C
+#define OV2650_EXVTS_H	0x302D
+#define OV2650_EXVTS_L	0x302E
+#define OV2650_WET_0	0x3030
+#define OV2650_WET_1	0x3031
+#define OV2650_WET_2	0x3032
+#define OV2650_WET_3	0x3033
+#define OV2650_AHS_H	0x3038
+#define OV2650_AHS_L	0x3039
+#define OV2650_AVS_H	0x303A
+#define OV2650_AVS_L	0x303B
+#define OV2650_AHW_H	0x303C
+#define OV2650_AHW_L	0x303D
+#define OV2650_AVH_H	0x303E
+#define OV2650_AVH_L	0x303F
+#define OV2650_HISTO_0	0x3040
+#define OV2650_HISTO_1	0x3041
+#define OV2650_HISTO_2	0x3042
+#define OV2650_HISTO_3	0x3043
+#define OV2650_HISTO_4	0x3044
+#define OV2650_BLC9A	0x3069
+#define OV2650_BLCC		0x306C
+#define OV2650_BLCD		0x306D
+#define OV2650_BLCF		0x306F
+#define OV2650_BD50_L	0x3070
+#define OV2650_BD50_H	0x3071
+#define OV2650_BD60_L	0x3072
+#define OV2650_BD60_H	0x3073
+#define OV2650_TMC_0	0x3076
+#define OV2650_TMC_1	0x3077
+#define OV2650_TMC_2	0x3078
+#define OV2650_TMC_4	0x307A
+#define OV2650_TMC_6	0x307C
+#define OV2650_TMC_8	0x307E
+#define OV2650_TMC_I2C	0x3084
+#define OV2650_TMC_10	0x3086
+#define OV2650_TMC_11	0x3087
+#define OV2650_ISP_XO_H	0x3088
+#define OV2650_ISP_XO_L	0x3089
+#define OV2650_ISP_YO_H	0x308A
+#define OV2650_ISP_YO_L	0x308B
+#define OV2650_TMC_12	0x308C
+#define OV2650_TMC_13	0x308D
+#define OV2650_EFUSE	0x308F
+#define OV2650_IO_CTL_0	0x30B0
+#define OV2650_IO_CRL_1 0x30B1
+#define OV2650_IO_CTL_2 0x30B2
+#define OV2650_LAEC		0x30F0
+#define OV2650_GRP_EOP	0x30FF
+
+/* SC registers */
+#define OV2650_SC_CTL_0	0x3100
+#define OV2650_SC_SYN_CTL_0 0x3104
+#define OV2650_SC_SYN_CTL_1 0x3105
+#define OV2650_SC_SYN_CTL_3 0x3107
+#define OV2650_SC_SYN_CTL_4 0x3108
+
+/* DSP control register */
+#define OV2650_ISP_CTL_0	0x3300
+#define OV2650_ISP_CTL_1	0x3301
+#define OV2650_ISP_CTL_2	0x3302
+#define OV2650_ISP_CTL_3	0x3303
+#define OV2650_ISP_CTL_4	0x3304
+#define OV2650_ISP_CTL_5	0x3305
+#define OV2650_ISP_CTL_6	0x3306
+#define OV2650_ISP_CTL_7	0x3307
+#define OV2650_ISP_CTL_8	0x3308
+#define OV2650_ISP_CTL_9	0x3309
+#define OV2650_ISP_CTL_A	0x330A
+#define OV2650_ISP_CTL_B	0x330B
+#define OV2650_ISP_CTL_10	0x3310
+#define OV2650_ISP_CTL_11	0x3311
+#define OV2650_ISP_CTL_12	0x3312
+#define OV2650_ISP_CTL_13	0x3313
+#define OV2650_ISP_CTL_14	0x3314
+#define OV2650_ISP_CTL_15	0x3315
+#define OV2650_ISP_CTL_16	0x3316
+#define OV2650_ISP_CTL_17	0x3317
+#define OV2650_ISP_CTL_18	0x3318
+#define OV2650_ISP_CTL_19	0x3319
+#define OV2650_ISP_CTL_1A	0x331A
+#define OV2650_ISP_CTL_1B	0x331B
+#define OV2650_ISP_CTL_1C	0x331C
+#define OV2650_ISP_CTL_1D	0x331D
+#define OV2650_ISP_CTL_1E	0x331E
+#define OV2650_ISP_CTL_20	0x3320
+#define OV2650_ISP_CTL_21	0x3321
+#define OV2650_ISP_CTL_22	0x3322
+#define OV2650_ISP_CTL_23	0x3323
+#define OV2650_ISP_CTL_24	0x3324
+#define OV2650_ISP_CTL_27	0x3327
+#define OV2650_ISP_CTL_28	0x3328
+#define OV2650_ISP_CTL_29	0x3329
+#define OV2650_ISP_CTL_2A	0x332A
+#define OV2650_ISP_CTL_2B	0x332B
+#define OV2650_ISP_CTL_2C	0x332C
+#define OV2650_ISP_CTL_2D	0x332D
+#define OV2650_ISP_CTL_2E	0x332E
+#define OV2650_ISP_CTL_2F	0x332F
+#define OV2650_ISP_CTL_30	0x3330
+#define OV2650_ISP_CTL_31	0x3331
+#define OV2650_ISP_CTL_32	0x3332
+#define OV2650_ISP_CTL_33	0x3333
+#define OV2650_ISP_CTL_34	0x3334
+#define OV2650_ISP_CTL_35	0x3335
+#define OV2650_ISP_CTL_36	0x3336
+#define OV2650_ISP_CTL_40	0x3340
+#define OV2650_ISP_CTL_41	0x3341
+#define OV2650_ISP_CTL_42	0x3342
+#define OV2650_ISP_CTL_43	0x3343
+#define OV2650_ISP_CTL_44	0x3344
+#define OV2650_ISP_CTL_45	0x3345
+#define OV2650_ISP_CTL_46	0x3346
+#define OV2650_ISP_CTL_47	0x3347
+#define OV2650_ISP_CTL_48	0x3348
+#define OV2650_ISP_CTL_49	0x3349
+#define OV2650_ISP_CTL_4A	0x334A
+#define OV2650_ISP_CTL_4B	0x334B
+#define OV2650_ISP_CTL_4C	0x334C
+#define OV2650_ISP_CTL_4D	0x334D
+#define OV2650_ISP_CTL_4E	0x334E
+#define OV2650_ISP_CTL_4F	0x334F
+#define OV2650_ISP_CTL_50	0x3350
+#define OV2650_ISP_CTL_51	0x3351
+#define OV2650_ISP_CTL_52	0x3352
+#define OV2650_ISP_CTL_53	0x3353
+#define OV2650_ISP_CTL_54	0x3354
+#define OV2650_ISP_CTL_55	0x3355
+#define OV2650_ISP_CTL_56	0x3356
+#define OV2650_ISP_CTL_57	0x3357
+#define OV2650_ISP_CTL_58	0x3358
+#define OV2650_ISP_CTL_59	0x3359
+#define OV2650_ISP_CTL_5A	0x335A
+#define OV2650_ISP_CTL_5B	0x335B
+#define OV2650_ISP_CTL_5C	0x335C
+#define OV2650_ISP_CTL_5D	0x335D
+#define OV2650_ISP_CTL_5E	0x335E
+#define OV2650_ISP_CTL_5F	0x335F
+#define OV2650_ISP_CTL_60	0x3360
+#define OV2650_ISP_CTL_61	0x3361
+#define OV2650_ISP_CTL_62	0x3362
+#define OV2650_ISP_CTL_63	0x3363
+#define OV2650_ISP_CTL_64	0x3364
+#define OV2650_ISP_CTL_65	0x3365
+#define OV2650_ISP_CTL_6A	0x336A
+#define OV2650_ISP_CTL_6B	0x336B
+#define OV2650_ISP_CTL_6C	0x336C
+#define OV2650_ISP_CTL_6E	0x336E
+#define OV2650_ISP_CTL_71	0x3371
+#define OV2650_ISP_CTL_72	0x3372
+#define OV2650_ISP_CTL_73	0x3373
+#define OV2650_ISP_CTL_74	0x3374
+#define OV2650_ISP_CTL_75	0x3375
+#define OV2650_ISP_CTL_76	0x3376
+#define OV2650_ISP_CTL_77	0x3377
+#define OV2650_ISP_CTL_78	0x3378
+#define OV2650_ISP_CTL_79	0x3379
+#define OV2650_ISP_CTL_7A	0x337A
+#define OV2650_ISP_CTL_7B	0x337B
+#define OV2650_ISP_CTL_7C	0x337C
+#define OV2650_ISP_CTL_80	0x3380
+#define OV2650_ISP_CTL_81	0x3381
+#define OV2650_ISP_CTL_82	0x3382
+#define OV2650_ISP_CTL_83	0x3383
+#define OV2650_ISP_CTL_84	0x3384
+#define OV2650_ISP_CTL_85	0x3385
+#define OV2650_ISP_CTL_86	0x3386
+#define OV2650_ISP_CTL_87	0x3387
+#define OV2650_ISP_CTL_88	0x3388
+#define OV2650_ISP_CTL_89	0x3389
+#define OV2650_ISP_CTL_8A	0x338A
+#define OV2650_ISP_CTL_8B	0x338B
+#define OV2650_ISP_CTL_8C	0x338C
+#define OV2650_ISP_CTL_8D	0x338D
+#define OV2650_ISP_CTL_8E	0x338E
+#define OV2650_ISP_CTL_90	0x3390
+#define OV2650_ISP_CTL_91	0x3391
+#define OV2650_ISP_CTL_92	0x3392
+#define OV2650_ISP_CTL_93	0x3393
+#define OV2650_ISP_CTL_94	0x3394
+#define OV2650_ISP_CTL_95	0x3395
+#define OV2650_ISP_CTL_96	0x3396
+#define OV2650_ISP_CTL_97	0x3397
+#define OV2650_ISP_CTL_98	0x3398
+#define OV2650_ISP_CTL_99	0x3399
+#define OV2650_ISP_CTL_9A	0x339A
+#define OV2650_ISP_CTL_A0	0x33A0
+#define OV2650_ISP_CTL_A1	0x33A1
+#define OV2650_ISP_CTL_A2	0x33A2
+#define OV2650_ISP_CTL_A3	0x33A3
+#define OV2650_ISP_CTL_A4	0x33A4
+#define OV2650_ISP_CTL_A5	0x33A5
+#define OV2650_ISP_CTL_A6	0x33A6
+#define OV2650_ISP_CTL_A7	0x33A7
+#define OV2650_ISP_CTL_A8	0x33A8
+#define OV2650_ISP_CTL_AA	0x33AA
+#define OV2650_ISP_CTL_AB	0x33AB
+#define OV2650_ISP_CTL_AC	0x33AC
+#define OV2650_ISP_CTL_AD	0x33AD
+#define OV2650_ISP_CTL_AE	0x33AE
+#define OV2650_ISP_CTL_AF	0x33AF
+#define OV2650_ISP_CTL_B0	0x33B0
+#define OV2650_ISP_CTL_B1	0x33B1
+#define OV2650_ISP_CTL_B2	0x33B2
+#define OV2650_ISP_CTL_B3	0x33B3
+#define OV2650_ISP_CTL_B4	0x33B4
+#define OV2650_ISP_CTL_B5	0x33B5
+#define OV2650_ISP_CTL_B6	0x33B6
+#define OV2650_ISP_CTL_B7	0x33B7
+#define OV2650_ISP_CTL_B8	0x33B8
+#define OV2650_ISP_CTL_B9	0x33B9
+
+/* Format register */
+#define OV2650_FMT_CTL_0	0x3400
+#define OV2650_FMT_CTL_1	0x3401
+#define OV2650_FMT_CTL_2	0x3402
+#define OV2650_FMT_CTL_3	0x3403
+#define OV2650_FMT_CTL_4	0x3404
+#define OV2650_FMT_CTL_5	0x3405
+#define OV2650_FMT_CTL_6	0x3406
+#define OV2650_FMT_CTL_7	0x3407
+#define OV2650_FMT_CTL_8	0x3408
+#define OV2650_DITHER_CTL	0x3409
+#define OV2650_DVP_CTL_0	0x3600
+#define OV2650_DVP_CTL_1	0x3601
+#define OV2650_DVP_CTL_6	0x3606
+#define OV2650_DVP_CTL_7	0x3607
+#define OV2650_DVP_CTL_9	0x3609
+#define OV2650_DVP_CTL_B 	0x360B
+
+/* General definition for ov2650 */
+#define OV2650_OUTWND_MAX_H		UXGA_SIZE_H
+#define OV2650_OUTWND_MAX_V		UXGA_SIZE_V
+
+struct regval_list {
+	u16 reg_num;
+	u8 value;
+};
+
+/*
+ * Default register value
+ * 1600x1200 YUV
+ */
+static struct regval_list ov2650_def_reg[] = {
+	{0x3012, 0x80},
+	{0x308c, 0x80},
+	{0x308d, 0x0e},
+	{0x360b, 0x00},
+	{0x30b0, 0xff},
+	{0x30b1, 0xff},
+	{0x30b2, 0x27},
+
+	{0x300e, 0x34},
+	{0x300f, 0xa6},
+	{0x3010, 0x81},
+	{0x3082, 0x01},
+	{0x30f4, 0x01},
+	{0x3090, 0x33},
+	{0x3091, 0xc0},
+	{0x30ac, 0x42},
+
+	{0x30d1, 0x08},
+	{0x30a8, 0x56},
+	{0x3015, 0x03},
+	{0x3093, 0x00},
+	{0x307e, 0xe5},
+	{0x3079, 0x00},
+	{0x30aa, 0x42},
+	{0x3017, 0x40},
+	{0x30f3, 0x82},
+	{0x306a, 0x0c},
+	{0x306d, 0x00},
+	{0x336a, 0x3c},
+	{0x3076, 0x6a},
+	{0x30d9, 0x8c},
+	{0x3016, 0x82},
+	{0x3601, 0x30},
+	{0x304e, 0x88},
+	{0x30f1, 0x82},
+	{0x3011, 0x02},
+
+	{0x3013, 0xf7},
+	{0x301c, 0x13},
+	{0x301d, 0x17},
+	{0x3070, 0x3e},
+	{0x3072, 0x34},
+
+	{0x30af, 0x00},
+	{0x3048, 0x1f},
+	{0x3049, 0x4e},
+	{0x304a, 0x20},
+	{0x304f, 0x20},
+	{0x304b, 0x02},
+	{0x304c, 0x00},
+	{0x304d, 0x02},
+	{0x304f, 0x20},
+	{0x30a3, 0x10},
+	{0x3013, 0xf7},
+	{0x3014, 0x44},
+	{0x3071, 0x00},
+	{0x3070, 0x3e},
+	{0x3073, 0x00},
+	{0x3072, 0x34},
+	{0x301c, 0x12},
+	{0x301d, 0x16},
+	{0x304d, 0x42},
+	{0x304a, 0x40},
+	{0x304f, 0x40},
+	{0x3095, 0x07},
+	{0x3096, 0x16},
+	{0x3097, 0x1d},
+
+	{0x3020, 0x01},
+	{0x3021, 0x18},
+	{0x3022, 0x00},
+	{0x3023, 0x0a},
+	{0x3024, 0x06},
+	{0x3025, 0x58},
+	{0x3026, 0x04},
+	{0x3027, 0xbc},
+	{0x3088, 0x06},
+	{0x3089, 0x40},
+	{0x308a, 0x04},
+	{0x308b, 0xb0},
+	{0x3316, 0x64},
+	{0x3317, 0x4b},
+	{0x3318, 0x00},
+	{0x331a, 0x64},
+	{0x331b, 0x4b},
+	{0x331c, 0x00},
+	{0x3100, 0x00},
+
+	{0x3320, 0xfa},
+	{0x3321, 0x11},
+	{0x3322, 0x92},
+	{0x3323, 0x01},
+	{0x3324, 0x97},
+	{0x3325, 0x02},
+	{0x3326, 0xff},
+	{0x3327, 0x0c},
+	{0x3328, 0x10},
+	{0x3329, 0x10},
+	{0x332a, 0x58},
+	{0x332b, 0x50},
+	{0x332c, 0xbe},
+	{0x332d, 0xe1},
+	{0x332e, 0x43},
+	{0x332f, 0x36},
+	{0x3330, 0x4d},
+	{0x3331, 0x44},
+	{0x3332, 0xf8},
+	{0x3333, 0x0a},
+	{0x3334, 0xf0},
+	{0x3335, 0xf0},
+	{0x3336, 0xf0},
+	{0x3337, 0x40},
+	{0x3338, 0x40},
+	{0x3339, 0x40},
+	{0x333a, 0x00},
+	{0x333b, 0x00},
+
+	{0x3380, 0x28},
+	{0x3381, 0x48},
+	{0x3382, 0x10},
+	{0x3383, 0x23},
+	{0x3384, 0xc0},
+	{0x3385, 0xe5},
+	{0x3386, 0xc2},
+	{0x3387, 0xb3},
+	{0x3388, 0x0e},
+	{0x3389, 0x98},
+	{0x338a, 0x01},
+
+	{0x3340, 0x0e},
+	{0x3341, 0x1a},
+	{0x3342, 0x31},
+	{0x3343, 0x45},
+	{0x3344, 0x5a},
+	{0x3345, 0x69},
+	{0x3346, 0x75},
+	{0x3347, 0x7e},
+	{0x3348, 0x88},
+	{0x3349, 0x96},
+	{0x334a, 0xa3},
+	{0x334b, 0xaf},
+	{0x334c, 0xc4},
+	{0x334d, 0xd7},
+	{0x334e, 0xe8},
+	{0x334f, 0x20},
+
+	{0x3350, 0x32},
+	{0x3351, 0x25},
+	{0x3352, 0x80},
+	{0x3353, 0x1e},
+	{0x3354, 0x00},
+	{0x3355, 0x85},
+	{0x3356, 0x32},
+	{0x3357, 0x25},
+	{0x3358, 0x80},
+	{0x3359, 0x1b},
+	{0x335a, 0x00},
+	{0x335b, 0x85},
+	{0x335c, 0x32},
+	{0x335d, 0x25},
+	{0x335e, 0x80},
+	{0x335f, 0x1b},
+	{0x3360, 0x00},
+	{0x3361, 0x85},
+	{0x3363, 0x70},
+	{0x3364, 0x7f},
+	{0x3365, 0x00},
+	{0x3366, 0x00},
+
+	{0x3301, 0xff},
+	{0x338B, 0x11},
+	{0x338c, 0x10},
+	{0x338d, 0x40},
+
+	{0x3370, 0xd0},
+	{0x3371, 0x00},
+	{0x3372, 0x00},
+	{0x3373, 0x40},
+	{0x3374, 0x10},
+	{0x3375, 0x10},
+	{0x3376, 0x04},
+	{0x3377, 0x00},
+	{0x3378, 0x04},
+	{0x3379, 0x80},
+
+	{0x3069, 0x84},
+	{0x307c, 0x10},
+	{0x3087, 0x02},
+
+	{0x3300, 0xfc},
+	{0x3302, 0x01},
+	{0x3400, 0x00},
+	{0x3606, 0x20},
+	{0x3601, 0x30},
+	{0x30f3, 0x83},
+	{0x304e, 0x88},
+
+	{0x3086, 0x0f},
+	{0x3086, 0x00},
+
+	{0xffff, 0xff},
+};
+
+/* 800x600 */
+static struct regval_list ov2650_res_svga[] = {
+
+	{0x306f, 0x14},
+	{0x302a, 0x02},
+	{0x302b, 0x84},
+	{0x3012, 0x10},
+	{0x3011, 0x01},
+
+	{0x3070, 0x5d},
+	{0x3072, 0x4d},
+
+	{0x3014, 0x84},
+	{0x301c, 0x07},
+	{0x301d, 0x09},
+	{0x3070, 0x50},
+	{0x3071, 0x00},
+	{0x3072, 0x42},
+	{0x3073, 0x00},
+
+	{0x3020, 0x01},
+	{0x3021, 0x18},
+	{0x3022, 0x00},
+	{0x3023, 0x06},
+	{0x3024, 0x06},
+	{0x3025, 0x58},
+	{0x3026, 0x02},
+	{0x3027, 0x5e},
+	{0x3088, 0x03},
+	{0x3089, 0x20},
+	{0x308a, 0x02},
+	{0x308b, 0x58},
+	{0x3316, 0x64},
+	{0x3317, 0x25},
+	{0x3318, 0x80},
+	{0x3319, 0x08},
+	{0x331a, 0x64},
+	{0x331b, 0x4b},
+	{0x331c, 0x00},
+	{0x331d, 0x38},
+	{0x3100, 0x00},
+
+	{0x3302, 0x11},
+
+	{0x3011, 0x01},
+	{0x300f, 0xa6},
+	{0x300e, 0x36},
+	{0x3010, 0x81},
+	{0x302e, 0x00},
+	{0x302d, 0x00},
+	{0x302c, 0x00},
+	{0x302b, 0x84},
+	{0x3014, 0x84},
+	{0x301c, 0x07},
+	{0x301d, 0x09},
+	{0x3070, 0x50},
+	{0x3071, 0x00},
+	{0x3072, 0x42},
+	{0x3073, 0x00},
+
+	{0x3086, 0x0f},
+	{0x3086, 0x00},
+	{0xffff, 0xff},
+};
+
+/* 640x480 */
+static struct regval_list ov2650_res_vga_vario[] = {
+	{0x306f, 0x14},
+	{0x302a, 0x02},
+	{0x302b, 0x6a},
+	{0x3012, 0x10},
+	{0x3011, 0x01},
+
+	{0x3070, 0x5d},
+	{0x3072, 0x4d},
+
+	{0x301c, 0x05},
+	{0x301d, 0x06},
+
+	{0x3020, 0x01},
+	{0x3021, 0x18},
+	{0x3022, 0x00},
+	{0x3023, 0x06},
+	{0x3024, 0x06},
+	{0x3025, 0x58},
+	{0x3026, 0x02},
+	{0x3027, 0x61},
+	{0x3088, 0x02},
+	{0x3089, 0x80},
+	{0x308a, 0x01},
+	{0x308b, 0xe0},
+	{0x3316, 0x64},
+	{0x3317, 0x25},
+	{0x3318, 0x80},
+	{0x3319, 0x08},
+	{0x331a, 0x28},
+	{0x331b, 0x1e},
+	{0x331c, 0x00},
+	{0x331d, 0x38},
+	{0x3100, 0x00},
+
+	{0x3302, 0x11},
+	{0x3011, 0x00},
+
+	{0x3014, 0x84}, /* note this */
+	{0x3086, 0x0f},
+	{0x3086, 0x00},
+	{0xffff, 0xff},
+};
+
+/* 640x480 reverse */
+/*
+static struct regval_list ov2650_res_vga_reverse[] = {
+	{0x306f, 0x10},
+	{0x302a, 0x04},
+	{0x302b, 0xd4},
+	{0x3012, 0x00},
+	{0x3011, 0x02},
+
+	{0x3070, 0x3e},
+	{0x3072, 0x34},
+
+	{0x301c, 0x12},
+	{0x301d, 0x16},
+
+	{0x3020, 0x01},
+	{0x3021, 0x18},
+	{0x3022, 0x00},
+	{0x3023, 0x0a},
+	{0x3024, 0x06},
+	{0x3025, 0x58},
+	{0x3026, 0x04},
+	{0x3027, 0xbc},
+	{0x3088, 0x06},
+	{0x3089, 0x40},
+	{0x308a, 0x04},
+	{0x308b, 0xb0},
+	{0x3316, 0x64},
+	{0x3317, 0xb4},
+	{0x3318, 0x00},
+	{0x3319, 0x6c},
+	{0x331a, 0x64},
+	{0x331b, 0x4b},
+	{0x331c, 0x00},
+	{0x331d, 0x6c},
+	{0x3100, 0x00},
+
+	{0x3302, 0x01},
+	{0x3011, 0x02},
+
+	{0x3014, 0x44},
+	{0x3086, 0x0f},
+	{0x3086, 0x00},
+	{0xffff, 0xff},
+};
+
+*/
+/* 320x240 */
+static struct regval_list ov2650_res_qvga[] = {
+	{0x306f, 0x14},
+	{0x302a, 0x02},
+	{0x302b, 0x6a},
+
+	{0x3012, 0x10},
+	{0x3011, 0x01},
+
+	{0x3070, 0x5d},
+	{0x3072, 0x4d},
+	{0x301c, 0x05},
+	{0x301d, 0x06},
+
+	{0x3023, 0x06},
+	{0x3026, 0x02},
+	{0x3027, 0x61},
+	{0x3088, 0x01},
+	{0x3089, 0x40},
+	{0x308a, 0x00},
+	{0x308b, 0xf0},
+	{0x3316, 0x64},
+	{0x3317, 0x25},
+	{0x3318, 0x80},
+	{0x3319, 0x08},
+	{0x331a, 0x14},
+	{0x331b, 0x0f},
+	{0x331c, 0x00},
+	{0x331d, 0x38},
+	{0x3100, 0x00},
+
+	{0x3015, 0x02}, /* note this */
+	{0x3014, 0x84},
+	{0x3302, 0x11},
+	{0x3086, 0x0f},
+	{0x3086, 0x00},
+	{0xffff, 0xff},
+};
+
+static struct regval_list ov2650_res_uxga[] = {
+	/* Note this added by debug */
+	{0x3014, 0x84},
+	{0x301c, 0x13},
+	{0x301d, 0x17},
+	{0x3070, 0x40},
+	{0x3071, 0x00},
+	{0x3072, 0x36},
+	{0x3073, 0x00},
+
+	{0xffff, 0xff},
+};
+
+static struct regval_list ov2650_res_sxga[] = {
+	{0x3011, 0x02},
+
+	{0x3020, 0x01},
+	{0x3021, 0x18},
+	{0x3022, 0x00},
+	{0x3023, 0x0a},
+	{0x3024, 0x06},
+	{0x3025, 0x58},
+	{0x3026, 0x04},
+	{0x3027, 0xbc},
+	{0x3088, 0x05},
+	{0x3089, 0x00},
+	{0x308a, 0x04},
+	{0x308b, 0x00},
+	{0x3316, 0x64},
+	{0x3317, 0x4b},
+	{0x3318, 0x00},
+	{0x331a, 0x50},
+	{0x331b, 0x40},
+	{0x331c, 0x00},
+
+	{0x3302, 0x11},
+
+	{0x3014, 0x84},
+	{0x301c, 0x13},
+	{0x301d, 0x17},
+	{0x3070, 0x40},
+	{0x3071, 0x00},
+	{0x3072, 0x36},
+	{0x3073, 0x00},
+
+	{0x3086, 0x0f},
+	{0x3086, 0x00},
+	{0xffff, 0xff},
+};
diff --git a/drivers/media/video/mrstci/mrstov5630/Kconfig b/drivers/media/video/mrstci/mrstov5630/Kconfig
new file mode 100644
index 0000000..a28ddc2
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_MRST_OV5630
+	tristate "Moorestown OV5630 RAW Sensor"
+	depends on I2C && VIDEO_MRST_ISP
+
+	---help---
+	  Say Y here if your platform support OV5630 RAW Sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mrstov2650.ko.
diff --git a/drivers/media/video/mrstci/mrstov5630/Makefile b/drivers/media/video/mrstci/mrstov5630/Makefile
new file mode 100644
index 0000000..c67abff
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630/Makefile
@@ -0,0 +1,4 @@
+mrstov5630-objs 	= ov5630.o
+obj-$(CONFIG_VIDEO_MRST_OV5630)	 += mrstov5630.o
+
+EXTRA_CFLAGS	+=	-I$(src)/../include
diff --git a/drivers/media/video/mrstci/mrstov5630/ov5630.c b/drivers/media/video/mrstci/mrstov5630/ov5630.c
new file mode 100644
index 0000000..6498153
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630/ov5630.c
@@ -0,0 +1,1153 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
+
+#include "ci_sensor_common.h"
+#include "ov5630.h"
+
+static int mrstov5630_debug;
+module_param(mrstov5630_debug, int, 0644);
+MODULE_PARM_DESC(mrstov5630_debug, "Debug level (0-1)");
+
+#define dprintk(level, fmt, arg...) do {			\
+	if (mrstov5630_debug >= level) 					\
+		printk(KERN_DEBUG "mrstisp@%s: " fmt "\n",	\
+		       __func__, ## arg); } \
+	while (0)
+
+#define eprintk(fmt, arg...)	\
+	printk(KERN_ERR "mrstisp@%s: line %d: " fmt "\n",	\
+	       __func__, __LINE__, ## arg);
+
+#define DBG_entering	dprintk(2, "entering");
+#define DBG_leaving	dprintk(2, "leaving");
+#define DBG_line	dprintk(2, " line: %d", __LINE__);
+
+static inline struct ci_sensor_config *to_sensor_config(struct v4l2_subdev *sd)
+{
+	return container_of(sd, struct ci_sensor_config, sd);
+}
+
+/* static int ov5630_set_res(struct i2c_client *c, const int w, const int h);
+ */
+static struct ov5630_format_struct {
+	__u8 *desc;
+	__u32 pixelformat;
+	struct regval_list *regs;
+} ov5630_formats[] = {
+	{
+		.desc		= "Raw RGB Bayer",
+		.pixelformat	= SENSOR_MODE_BAYER,
+		.regs 		= NULL,
+	},
+};
+#define N_OV5630_FMTS ARRAY_SIZE(ov5630_formats)
+
+static struct ov5630_res_struct {
+	__u8 *desc;
+	int res;
+	int width;
+	int height;
+	/* FIXME: correct the fps values.. */
+	int fps;
+	bool used;
+	struct regval_list *regs;
+} ov5630_res[] = {
+	{
+		.desc		= "QSXGA_PLUS4",
+		.res		= SENSOR_RES_QXGA_PLUS,
+		.width		= 2592,
+		.height		= 1944,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov5630_res_qsxga_plus4,
+	},
+	{
+		.desc		= "1080P",
+		.res		= SENSOR_RES_1080P,
+		.width		= 1920,
+		.height		= 1080,
+		.fps		= 25,
+		.used		= 0,
+		.regs		= ov5630_res_1080p,
+	},
+	{
+		.desc 		= "XGA_PLUS",
+		.res		= SENSOR_RES_XGA_PLUS,
+		.width		= 1280,
+		.height		= 960,
+		.fps		= 30,
+		.used		= 0,
+		.regs		= ov5630_res_xga_plus,
+	},
+	{
+		.desc		= "720p",
+		.res		= SENSOR_RES_720P,
+		.width		= 1280,
+		.height		= 720,
+		.fps		= 34,
+		.used		= 0,
+		.regs		= ov5630_res_720p,
+	},
+	{
+		.desc 		= "VGA",
+		.res		= SENSOR_RES_VGA,
+		.width		= 640,
+		.height		= 480,
+		.fps		= 39,
+		.used		= 0,
+		.regs		= ov5630_res_vga_ac04_bill,
+	},
+};
+
+#define N_RES (ARRAY_SIZE(ov5630_res))
+
+/*
+ * I2C Read & Write stuff
+ */
+static int ov5630_read(struct i2c_client *c, u32 reg, u32 *value)
+{
+	int ret;
+	int i;
+	struct i2c_msg msg[2];
+	u8 msgbuf[2];
+	u8 ret_val = 0;
+	*value = 0;
+	/* Read needs two message to go */
+	memset(&msg, 0, sizeof(msg));
+	msgbuf[0] = 0;
+	msgbuf[1] = 0;
+	i = 0;
+
+	msgbuf[i++] = ((u16)reg) >> 8;
+	msgbuf[i++] = ((u16)reg) & 0xff;
+	msg[0].addr = c->addr;
+	msg[0].buf = msgbuf;
+	msg[0].len = i;
+
+	msg[1].addr = c->addr;
+	msg[1].flags = I2C_M_RD;
+	msg[1].buf = &ret_val;
+	msg[1].len = 1;
+
+	ret = i2c_transfer(c->adapter, &msg[0], 2);
+	*value = ret_val;
+
+	ret = (ret == 2) ? 0 : -1;
+	return ret;
+}
+
+static int ov5630_write(struct i2c_client *c, u32 reg, u32 value)
+{
+	int ret, i;
+	struct i2c_msg msg;
+	u8 msgbuf[3];
+
+	/* Writing only needs one message */
+	memset(&msg, 0, sizeof(msg));
+	i = 0;
+	msgbuf[i++] = ((u16)reg) >> 8;
+	msgbuf[i++] = (u16)reg & 0xff;
+	msgbuf[i++] = (u8)value;
+
+	msg.addr = c->addr;
+	msg.flags = 0;
+	msg.buf = msgbuf;
+	msg.len = i;
+
+	ret = i2c_transfer(c->adapter, &msg, 1);
+
+	/* If this is a reset register, wait for 1ms */
+	if (reg == OV5630_SYS && (value & 0x80))
+		msleep(3);
+
+	ret = (ret == 1) ? 0 : -1;
+	return ret;
+}
+
+static int ov5630_write_array(struct i2c_client *c, struct regval_list *vals)
+{
+	struct regval_list *p;
+	u32 read_val = 0;
+	int err_num = 0;
+	int i = 0;
+	p = vals;
+	while (p->reg_num != 0xffff) {
+		ov5630_write(c, (u32)p->reg_num, (u32)p->value);
+		ov5630_read(c, (u32)p->reg_num, &read_val);
+		if (read_val != p->value)
+			err_num++;
+		p++;
+		i++;
+	}
+	return 0;
+}
+
+/*
+ * Sensor specific helper function
+ */
+static int ov5630_standby(void)
+{
+	gpio_set_value(GPIO_STDBY_PIN, 1);
+	/* ov5630_motor_standby(); */
+	dprintk(1, "PM: standby called\n");
+	return 0;
+}
+
+static int ov5630_wakeup(void)
+{
+	gpio_set_value(GPIO_STDBY_PIN, 0);
+	/* ov5630_motor_wakeup(); */
+	dprintk(1, "PM: wakeup called\n");
+	return 0;
+}
+
+static int ov5630_s_power(struct v4l2_subdev *sd, u32 val)
+{
+	if (val == 1)
+		ov5630_standby();
+	if (val == 0)
+		ov5630_wakeup();
+	return 0;
+}
+
+static int ov5630_set_img_ctrl(struct i2c_client *c,
+			       const struct ci_sensor_config *config)
+{
+	int err = 0;
+	u32 reg_val = 0;
+	/* struct ci_sensor_config *info = i2c_get_clientdata(c); */
+
+	switch (config->blc) {
+	case SENSOR_BLC_OFF:
+		err |= ov5630_read(c, OV5630_ISP_CTL00, &reg_val);
+		err |= ov5630_write(c, OV5630_ISP_CTL00, reg_val & 0xFE);
+		break;
+	case SENSOR_BLC_AUTO:
+		err |= ov5630_read(c, OV5630_ISP_CTL00, &reg_val);
+		err |= ov5630_write(c, OV5630_ISP_CTL00, reg_val | 0x01);
+		break;
+	}
+
+	switch (config->agc) {
+	case SENSOR_AGC_AUTO:
+		err |= ov5630_read(c, OV5630_AUTO_1, &reg_val);
+		err |= ov5630_write(c, OV5630_AUTO_1, reg_val | 0x04);
+		break;
+	case SENSOR_AGC_OFF:
+		err |= ov5630_read(c, OV5630_AUTO_1, &reg_val);
+		err |= ov5630_write(c, OV5630_AUTO_1, reg_val & ~0x04);
+		break;
+	}
+
+	switch (config->awb) {
+	case SENSOR_AWB_AUTO:
+		err |= ov5630_read(c, OV5630_ISP_CTL00, &reg_val);
+		err |= ov5630_write(c, OV5630_ISP_CTL00, reg_val | 0x30);
+		break;
+	case SENSOR_AWB_OFF:
+		err |= ov5630_read(c, OV5630_ISP_CTL00, &reg_val);
+		err |= ov5630_write(c, OV5630_ISP_CTL00, reg_val & ~0x30);
+		break;
+	}
+
+	switch (config->aec) {
+	case SENSOR_AEC_AUTO:
+		err |= ov5630_read(c, OV5630_AUTO_1, &reg_val);
+		err |= ov5630_write(c, OV5630_AUTO_1, reg_val | 0xFB);
+		break;
+	case SENSOR_AEC_OFF:
+		err |= ov5630_read(c, OV5630_AUTO_1, &reg_val);
+		err |= ov5630_write(c, OV5630_AUTO_1, reg_val & 0xF6);
+		break;
+	}
+
+	return err;
+}
+
+static int ov5630_init(struct i2c_client *c)
+{
+	int ret;
+	struct v4l2_subdev *sd = i2c_get_clientdata(c);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	char *name = "";
+
+	/* Fill the configuration structure */
+	/* Note this default configuration value */
+	info->mode = ov5630_formats[0].pixelformat;
+	info->res = ov5630_res[0].res;
+	info->type = SENSOR_TYPE_RAW;
+	info->bls = SENSOR_BLS_OFF;
+	info->gamma = SENSOR_GAMMA_OFF;
+	info->cconv = SENSOR_CCONV_OFF;
+	info->blc = SENSOR_BLC_AUTO;
+	info->agc = SENSOR_AGC_AUTO;
+	info->awb = SENSOR_AWB_AUTO;
+	info->aec = SENSOR_AEC_AUTO;
+	/* info->bus_width = SENSOR_BUSWIDTH_10BIT; */
+	info->bus_width = SENSOR_BUSWIDTH_10BIT_ZZ;
+	info->ycseq = SENSOR_YCSEQ_YCBYCR;
+	/* info->conv422 = SENSOR_CONV422_NOCOSITED; */
+	info->conv422 = SENSOR_CONV422_COSITED;
+	info->bpat = SENSOR_BPAT_BGBGGRGR;
+	info->field_inv = SENSOR_FIELDINV_NOSWAP;
+	info->field_sel = SENSOR_FIELDSEL_BOTH;
+	info->hpol = SENSOR_HPOL_REFPOS;
+	info->vpol = SENSOR_VPOL_NEG;
+	info->edge = SENSOR_EDGE_RISING;
+	info->flicker_freq = SENSOR_FLICKER_100;
+	info->cie_profile = SENSOR_CIEPROF_F11;
+	name = "ov5630";
+	memcpy(info->name, name, 7);
+
+	/* Reset sensor hardware, and implement the setting*/
+	ret = ov5630_write(c, (u32)OV5630_SYS, (u32)0x80);
+	ret += ov5630_write(c, (u32)OV5630_IMAGE_SYSTEM, (u32)0x00);
+
+	/* Set registers into default config value */
+	ret += ov5630_write_array(c, ov5630_def_reg);
+
+	/* Set MIPI interface */
+#ifdef OV5630_MIPI
+	ret += ov5630_write_array(c, ov5630_mipi);
+#endif
+
+	/* turn off AE AEB AGC */
+	ret += ov5630_set_img_ctrl(c, info);
+
+	/* streaming */
+	/* ret += ov5630_write(c, (u32)OV5630_IMAGE_SYSTEM, (u32)0x01); */
+	/* ret += ov5630_write(c, (u32)0x3096, (u32)0x50); */
+	/* /ssleep(1); */
+
+	/* Added by wen to stop sensor from streaming */
+	ov5630_write(c, (u32)OV5630_IMAGE_SYSTEM, (u32)0x00);
+	ov5630_write(c, 0x30b0, 0x00);
+	ov5630_write(c, 0x30b1, 0x00);
+	return ret;
+}
+
+static int distance(struct ov5630_res_struct *res, u32 w, u32 h)
+{
+	int ret;
+	if (res->width < w || res->height < h)
+		return -1;
+
+	ret = ((res->width - w) + (res->height - h));
+	return ret;
+}
+static int ov5630_try_res(u32 *w, u32 *h)
+{
+	struct ov5630_res_struct *res_index, *p = NULL;
+	int dis, last_dis = ov5630_res->width + ov5630_res->height;
+
+	DBG_entering;
+
+	for (res_index = ov5630_res;
+	     res_index < ov5630_res + N_RES;
+	     res_index++) {
+		if ((res_index->width < *w) || (res_index->height < *h))
+			break;
+		dis = distance(res_index, *w, *h);
+		if (dis < last_dis) {
+			last_dis = dis;
+			p = res_index;
+		}
+	}
+
+	if (p == NULL)
+		p = ov5630_res;
+	else if ((p->width < *w) || (p->height < *h)) {
+		if (p != ov5630_res)
+			p--;
+	}
+
+	if ((w != NULL) && (h != NULL)) {
+		*w = p->width;
+		*h = p->height;
+	}
+
+	DBG_leaving;
+	return 0;
+}
+
+static struct ov5630_res_struct *ov5630_to_res(u32 w, u32 h)
+{
+	struct ov5630_res_struct *res_index;
+
+	for (res_index = ov5630_res;
+	     res_index < ov5630_res + N_RES;
+	     res_index++)
+		if ((res_index->width == w) && (res_index->height == h))
+			break;
+
+	if (res_index >= ov5630_res + N_RES)
+		res_index--;   /* Take the bigger one */
+
+	return res_index;
+}
+
+static int ov5630_try_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	DBG_entering;
+	return ov5630_try_res(&fmt->fmt.pix.width, &fmt->fmt.pix.height);
+	DBG_leaving;
+}
+
+static int ov5630_get_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	unsigned short width, height;
+	int index;
+
+	ci_sensor_res2size(info->res, &width, &height);
+
+	/* Marked the current sensor res as being "used" */
+	for (index = 0; index < N_RES; index++) {
+		if ((width == ov5630_res[index].width) &&
+		    (height == ov5630_res[index].height)) {
+			ov5630_res[index].used = 1;
+			continue;
+		}
+		ov5630_res[index].used = 0;
+	}
+
+	fmt->fmt.pix.width = width;
+	fmt->fmt.pix.height = height;
+	return 0;
+}
+
+static int ov5630_set_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+{
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	int ret = 0;
+	struct ov5630_res_struct *res_index;
+	u32 width, height;
+	int index;
+
+	DBG_entering;
+
+	width = fmt->fmt.pix.width;
+	height = fmt->fmt.pix.height;
+
+	dprintk(1, "was told to set fmt (%d x %d) ", width, height);
+
+	ret = ov5630_try_res(&width, &height);
+
+	dprintk(1, "setting fmt (%d x %d) ", width, height);
+
+	res_index = ov5630_to_res(width, height);
+
+	ov5630_wakeup();
+
+	if (res_index->regs) {
+		/* Soft reset camera first*/
+		ret = ov5630_write(c, (u32)OV5630_SYS, (u32)0x80);
+
+		/* software sleep/standby */
+		ret += ov5630_write(c, (u32)OV5630_IMAGE_SYSTEM, (u32)0x00);
+
+		/* Set registers into default config value */
+		ret += ov5630_write_array(c, ov5630_def_reg);
+
+		/* set image resolution */
+		ret += ov5630_write_array(c, res_index->regs);
+
+		/* turn off AE AEB AGC */
+		ret += ov5630_set_img_ctrl(c, info);
+
+		/* Set MIPI interface */
+#ifdef OV5630_MIPI
+		ret += ov5630_write_array(c, ov5630_mipi);
+#endif
+
+		if (res_index->res == SENSOR_RES_VGA)
+			ret += ov5630_write(c, (u32)0x3015, (u32)0x03);
+
+		/* streaming */
+		ret = ov5630_write(c, (u32)OV5630_IMAGE_SYSTEM, (u32)0x01);
+		ret = ov5630_write(c, (u32)0x3096, (u32)0x50);
+
+		info->res = res_index->res;
+
+		/* Marked current sensor res as being "used" */
+		for (index = 0; index < N_RES; index++) {
+			if ((width == ov5630_res[index].width) &&
+			    (height == ov5630_res[index].height)) {
+				ov5630_res[index].used = 1;
+				continue;
+			}
+			ov5630_res[index].used = 0;
+		}
+
+		for (index = 0; index < N_RES; index++)
+			dprintk(2, "index = %d, used = %d\n", index,
+				ov5630_res[index].used);
+	} else {
+		eprintk("no res for (%d x %d)", width, height);
+	}
+
+	DBG_leaving;
+	return ret;
+}
+
+static int ov5630_t_gain(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	u32 v;
+
+	DBG_entering;
+
+	dprintk(2, "writing gain %x to 0x3000", value);
+
+	ov5630_read(client, 0x3000, &v);
+	v = (v & 0x80) + value;
+	ov5630_write(client, 0x3000, v);
+
+	dprintk(2, "gain %x was writen to 0x3000", v);
+
+	DBG_leaving;
+	return 0;
+}
+
+static int ov5630_t_exposure(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	u32 v;
+	u32 reg_val;
+
+	DBG_entering;
+
+	ov5630_read(client, 0x3013, &v);
+	dprintk(2, "0x3013 = %x", v);
+	if (v & 0x05) {
+		/* turn off agc/aec */
+		v = v & 0xfa;
+		ov5630_write(client, 0x3013, v);
+		/* turn off awb */
+		ov5630_read(client, OV5630_ISP_CTL00, &reg_val);
+		ov5630_write(client, OV5630_ISP_CTL00, reg_val & ~0x30);
+	}
+	ov5630_read(client, 0x3014, &v);
+	dprintk(2, "0x3014 = %x", v);
+	ov5630_read(client, 0x3002, &v);
+	dprintk(2, "0x3002 = %x", v);
+	ov5630_read(client, 0x3003, &v);
+	dprintk(2, "0x3003 = %x", v);
+
+	dprintk(2, "writing exposure %x to 0x3002/3", value);
+
+	v = value >> 8;
+	ov5630_write(client, 0x3002, v);
+	dprintk(2, "exposure %x was writen to 0x3002", v);
+
+	v = value & 0xff;
+	ov5630_write(client, 0x3003, v);
+	dprintk(2, "exposure %x was writen to 0x3003", v);
+
+	DBG_leaving;
+	return 0;
+}
+
+static struct ov5630_control {
+	struct v4l2_queryctrl qc;
+	int (*query)(struct v4l2_subdev *sd, __s32 *value);
+	int (*tweak)(struct v4l2_subdev *sd, int value);
+} ov5630_controls[] = {
+	{
+		.qc = {
+			.id = V4L2_CID_GAIN,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "global gain",
+			.minimum = 0x0,
+			.maximum = 0xFF,
+			.step = 0x01,
+			.default_value = 0x00,
+			.flags = 0,
+		},
+		.tweak = ov5630_t_gain,
+/* 		.query = ov5630_q_gain, */
+	},
+	{
+		.qc = {
+			.id = V4L2_CID_EXPOSURE,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "exposure",
+			.minimum = 0x0,
+			.maximum = 0xFFFF,
+			.step = 0x01,
+			.default_value = 0x00,
+			.flags = 0,
+		},
+		.tweak = ov5630_t_exposure,
+/* 		.query = ov5630_q_exposure; */
+	},
+};
+#define N_CONTROLS (ARRAY_SIZE(ov5630_controls))
+
+/*
+static int ov5630_g_gain(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	unsigned char v;
+
+	DBG_entering;
+
+	ov5630_write(client, 0x3000, &v);
+	dprintk(2, "writing gain %x to 0x3000", value);
+
+	value
+	DBG_leaving;
+	return 0
+}
+*/
+
+static struct ov5630_control *ov5630_find_control(__u32 id)
+{
+	int i;
+
+	for (i = 0; i < N_CONTROLS; i++)
+		if (ov5630_controls[i].qc.id == id)
+			return ov5630_controls + i;
+	return NULL;
+}
+
+static int ov5630_queryctrl(struct v4l2_subdev *sd,
+			    struct v4l2_queryctrl *qc)
+{
+	struct ov5630_control *ctrl = ov5630_find_control(qc->id);
+
+	if (ctrl == NULL)
+		return -EINVAL;
+	*qc = ctrl->qc;
+	return 0;
+}
+
+static int ov5630_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+	/*
+	struct ov5630_control *octrl = ov5630_find_control(ctrl->id);
+
+	int ret;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret = octrl->query(sd, &ctrl->value);
+	if (ret >= 0)
+		return 0;
+	return ret;
+	*/
+	return 0;
+}
+
+static int ov5630_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+	struct ov5630_control *octrl = ov5630_find_control(ctrl->id);
+	int ret;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret =  octrl->tweak(sd, ctrl->value);
+	if (ret >= 0)
+		return 0;
+	return ret;
+}
+
+#if 0
+static int ov5630_get_caps(struct i2c_client *c, struct ci_sensor_caps *caps)
+{
+	if (caps == NULL)
+		return -EIO;
+
+	caps->bus_width = SENSOR_BUSWIDTH_10BIT;
+	caps->mode	= SENSOR_MODE_BAYER;
+	caps->field_inv = SENSOR_FIELDINV_NOSWAP;
+	caps->field_sel = SENSOR_FIELDSEL_BOTH;
+	caps->ycseq	= SENSOR_YCSEQ_YCBYCR;
+	caps->conv422	= SENSOR_CONV422_NOCOSITED;
+	caps->bpat	= SENSOR_BPAT_BGBGGRGR;
+	caps->hpol	= SENSOR_HPOL_REFPOS;
+	caps->vpol	= SENSOR_VPOL_NEG;
+	caps->edge	= SENSOR_EDGE_RISING;
+	caps->bls	= SENSOR_BLS_OFF;
+	caps->gamma	= SENSOR_GAMMA_OFF;
+	caps->cconv	= SENSOR_CCONV_OFF;
+	caps->res	= SENSOR_RES_QXGA_PLUS | SENSOR_RES_1080P |
+	    SENSOR_RES_XGA_PLUS | SENSOR_RES_720P | SENSOR_RES_VGA;
+	caps->blc	= SENSOR_BLC_OFF;
+	caps->agc	= SENSOR_AGC_OFF;
+	caps->awb	= SENSOR_AWB_OFF;
+	caps->aec	= SENSOR_AEC_OFF;
+	caps->cie_profile = SENSOR_CIEPROF_D65 | SENSOR_CIEPROF_D75 |
+	    SENSOR_CIEPROF_F11 | SENSOR_CIEPROF_F12 | SENSOR_CIEPROF_A |
+	    SENSOR_CIEPROF_F2;
+	caps->flicker_freq	= SENSOR_FLICKER_100 | SENSOR_FLICKER_120;
+	caps->type	= SENSOR_TYPE_RAW;
+	/* caps->name	= "ov5630"; */
+	strcpy(caps->name, "ov5630");
+
+	return 0;
+}
+
+static int ov5630_get_config(struct i2c_client *c,
+			     struct ci_sensor_config *config)
+{
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+
+	if (config == NULL) {
+		printk(KERN_WARNING "sensor_get_config: NULL pointer\n");
+		return -EIO;
+	}
+
+	memcpy(config, info, sizeof(struct ci_sensor_config));
+
+	return 0;
+}
+
+static int ov5630_setup(struct i2c_client *c,
+			const struct ci_sensor_config *config)
+{
+	int ret;
+	u16 width, high;
+	struct ov5630_res_struct *res_index;
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+
+	/* Soft reset camera first*/
+	ret = ov5630_write(c, (u32)OV5630_SYS, (u32)0x80);
+
+	/* software sleep/standby */
+	ret = ov5630_write(c, (u32)OV5630_IMAGE_SYSTEM, (u32)0x00);
+
+	/* Set registers into default config value */
+	ret = ov5630_write_array(c, ov5630_def_reg);
+
+	/* set image resolution */
+	ci_sensor_res2size(config->res, &width, &high);
+	ret += ov5630_try_res(&width, &high);
+	res_index = ov5630_find_res(width, high);
+	if (res_index->regs)
+		ret += ov5630_write_array(c, res_index->regs);
+	if (!ret)
+		info->res = res_index->res;
+
+	ret += ov5630_set_img_ctrl(c, config);
+
+	/* Set MIPI interface */
+#ifdef OV5630_MIPI
+	ret += ov5630_write_array(c, ov5630_mipi);
+#endif
+
+	/* streaming */
+	ret += ov5630_write(c, (u32)OV5630_IMAGE_SYSTEM, (u32)0x01);
+	ret += ov5630_write(c, (u32)0x3096, (u32)0x50);
+
+	/*Note here for the time delay */
+	/* ssleep(1); */
+	msleep(500);
+	return ret;
+}
+
+/*
+ * File operation functions
+ */
+static int ov5630_dvp_enable(struct i2c_client *client)
+{
+	int ret;
+
+	u8 reg;
+
+	ret = ov5630_read(client, 0x3506, &reg);
+	reg &= 0xdf;
+	reg |= 0x20;
+	ret += ov5630_write(client, 0x3506, reg);
+
+	return ret;
+}
+
+static int ov5630_dvp_disable(struct i2c_client *client)
+{
+	int ret;
+
+	u8 reg;
+
+	ret = ov5630_read(client, 0x3506, &reg);
+	reg &= 0xdf;
+	ret += ov5630_write(client, 0x3506, reg);
+
+	return ret;
+}
+
+static int ov5630_open(struct i2c_setting *c, void *priv)
+{
+	/* Just wake up sensor */
+	if (ov5630_wakeup())
+		return -EIO;
+	ov5630_init(c->sensor_client);
+	/* ov5630_motor_init(c->motor_client); */
+	ov5630_write(c->sensor_client, (u32)OV5630_IMAGE_SYSTEM, (u32)0x00);
+
+	/* disable dvp_en */
+	ov5630_dvp_disable(c->sensor_client);
+
+	return 0;
+}
+
+static int ov5630_release(struct i2c_setting *c, void *priv)
+{
+	/* Just suspend the sensor */
+	if (ov5630_standby())
+		return -EIO;
+	return 0;
+}
+
+static int ov5630_on(struct i2c_setting *c)
+{
+	int ret;
+
+	/* Software wake up sensor */
+	ret = ov5630_write(c->sensor_client,
+			    (u32)OV5630_IMAGE_SYSTEM, (u32)0x01);
+
+	/* enable dvp_en */
+	return ret + ov5630_dvp_enable(c->sensor_client);
+}
+
+static int ov5630_off(struct i2c_setting *c)
+{
+	int ret;
+
+	/* Software standby sensor */
+	ret = ov5630_write(c->sensor_client,
+			    (u32)OV5630_IMAGE_SYSTEM, (u32)0x00);
+	/* disable dvp_en */
+	return ret + ov5630_dvp_disable(c->sensor_client);
+}
+
+static struct sensor_device ov5630 = {
+	.name	= "ov5630",
+	.type	= SENSOR_TYPE_RAW,
+	.minor	= -1,
+	.open	= ov5630_open,
+	.release = ov5630_release,
+	.on = ov5630_on,
+	.off = ov5630_off,
+	.querycap = ov5630_get_caps,
+	.get_config = ov5630_get_config,
+	.set_config = ov5630_setup,
+	.enum_parm = ov5630_queryctrl,
+	.get_parm = ov5630_g_ctrl,
+	.set_parm = ov5630_s_ctrl,
+	.try_res = ov5630_try_res,
+	.set_res = ov5630_set_res,
+	.get_ls_corr_config = NULL,
+	.mdi_get_focus = ov5630_motor_get_focus,
+	.mdi_set_focus = ov5630_motor_set_focus,
+	.mdi_max_step = ov5630_motor_max_step,
+	.mdi_calibrate = NULL,
+	.read = ov5630_read,
+	.write = ov5630_write,
+	.suspend = ov5630_standby,
+	.resume = ov5630_wakeup,
+	/* TBC */
+};
+#endif
+
+static int ov5630_s_stream(struct v4l2_subdev *sd, int enable)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	DBG_entering;
+
+	if (enable) {
+		ov5630_write(client, (u32)OV5630_IMAGE_SYSTEM, (u32)0x01);
+		ov5630_write(client, 0x30b0, 0xff);
+		ov5630_write(client, 0x30b1, 0xff);
+		msleep(500);
+	} else {
+		ov5630_write(client, (u32)OV5630_IMAGE_SYSTEM, (u32)0x00);
+		ov5630_write(client, 0x30b0, 0x00);
+		ov5630_write(client, 0x30b1, 0x00);
+	}
+
+	DBG_leaving;
+	return 0;
+}
+
+static int ov5630_enum_framesizes(struct v4l2_subdev *sd,
+				  struct v4l2_frmsizeenum *fsize)
+{
+	unsigned int index = fsize->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+	fsize->discrete.width = ov5630_res[index].width;
+	fsize->discrete.height = ov5630_res[index].height;
+	fsize->reserved[0] = ov5630_res[index].used;
+
+	DBG_leaving;
+
+	return 0;
+}
+
+static int ov5630_enum_frameintervals(struct v4l2_subdev *sd,
+				      struct v4l2_frmivalenum *fival)
+{
+	unsigned int index = fival->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+	fival->discrete.numerator = 1;
+	fival->discrete.denominator = ov5630_res[index].fps;
+
+	DBG_leaving;
+
+	return 0;
+}
+
+static int ov5630_g_chip_ident(struct v4l2_subdev *sd,
+		struct v4l2_dbg_chip_ident *chip)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+#define V4L2_IDENT_OV5630 8245
+	return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV5630, 0);
+}
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int ov5630_g_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	unsigned char val = 0;
+	int ret;
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	ret = ov5630_read(client, reg->reg & 0xffff, &val);
+	reg->val = val;
+	reg->size = 1;
+	return ret;
+}
+
+static int ov5630_s_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	ov5630_write(client, reg->reg & 0xffff, reg->val & 0xff);
+	return 0;
+}
+#endif
+
+static const struct v4l2_subdev_video_ops ov5630_video_ops = {
+	.try_fmt = ov5630_try_fmt,
+	.s_fmt = ov5630_set_fmt,
+	.g_fmt = ov5630_get_fmt,
+	.s_stream = ov5630_s_stream,
+	.enum_framesizes = ov5630_enum_framesizes,
+	.enum_frameintervals = ov5630_enum_frameintervals,
+};
+
+static const struct v4l2_subdev_core_ops ov5630_core_ops = {
+	.g_chip_ident = ov5630_g_chip_ident,
+	.queryctrl = ov5630_queryctrl,
+	.g_ctrl = ov5630_g_ctrl,
+	.s_ctrl = ov5630_s_ctrl,
+	.s_gpio = ov5630_s_power,
+	/*.g_ext_ctrls = ov5630_g_ext_ctrls,*/
+	/*.s_ext_ctrls = ov5630_s_ext_ctrls,*/
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+	.g_register = ov5630_g_register,
+	.s_register = ov5630_s_register,
+#endif
+};
+
+static const struct v4l2_subdev_ops ov5630_ops = {
+	.core = &ov5630_core_ops,
+	.video = &ov5630_video_ops,
+};
+
+/*
+ * Basic i2c stuff
+ */
+/*
+static unsigned short normal_i2c[] = {I2C_OV5630 >> 1,
+	I2C_CLIENT_END};
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver ov5630_driver;
+*/
+static int ov5630_detect(struct i2c_client *client)
+{
+	struct i2c_adapter *adapter = client->adapter;
+	int adap_id = i2c_adapter_id(adapter);
+	u32 value;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
+		eprintk("error i2c check func");
+		return -ENODEV;
+	}
+
+	if (adap_id != 1) {
+		eprintk("adap_id != 1");
+		return -ENODEV;
+	}
+
+	/* if (ov5630_wakeup()) */
+		/* return -ENODEV; */
+	ov5630_wakeup();
+
+	ov5630_read(client, (u32)OV5630_PID_H, &value);
+	if ((u8)value != 0x56) {
+		dprintk(1, "PID != 0x56, but %x", value);
+		dprintk(2, "client->addr = %x", client->addr);
+		return -ENODEV;
+	}
+
+	printk(KERN_INFO "Init ov5630 sensor success\n");
+	return 0;
+}
+
+static int ov5630_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	struct ci_sensor_config *info;
+	struct v4l2_subdev *sd;
+	int ret = -1;
+/* 	struct i2c_client *motor; */
+
+	DBG_entering;
+	v4l_info(client, "chip found @ 0x%x (%s)\n",
+		 client->addr << 1, client->adapter->name);
+	/*
+	 * Setup sensor configuration structure
+	 */
+	info = kzalloc(sizeof(struct ci_sensor_config), GFP_KERNEL);
+	if (!info) {
+		eprintk("fail to malloc for ci_sensor_config");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = ov5630_detect(client);
+	if (ret) {
+		dprintk(1, "error ov5630_detect");
+		goto out_free;
+	}
+
+	sd = &info->sd;
+	v4l2_i2c_subdev_init(sd, client, &ov5630_ops);
+
+	/*
+	 * Initialization OV5630
+	 * then turn into standby mode
+	 */
+	/* ret = ov5630_standby(); */
+	ret = ov5630_init(client);
+	if (ret) {
+		eprintk("error calling ov5630_init");
+		goto out_free;
+	}
+	ov5630_standby();
+
+	ret = 0;
+	goto out;
+
+out_free:
+	kfree(info);
+	DBG_leaving;
+out:
+	return ret;
+}
+
+/*
+ * XXX: Need to be checked
+ */
+static int ov5630_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+	DBG_entering;
+
+	v4l2_device_unregister_subdev(sd);
+	kfree(to_sensor_config(sd));
+
+	DBG_leaving;
+	return 0;
+}
+
+static const struct i2c_device_id ov5630_id[] = {
+	{"ov5630", 0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, ov5630_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = "ov5630",
+	.probe = ov5630_probe,
+	.remove = ov5630_remove,
+	/* .suspend = ov5630_suspend,
+	 * .resume = ov5630_resume, */
+	.id_table = ov5630_id,
+};
+
+MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
+MODULE_DESCRIPTION("A low-level driver for OmniVision 5630 sensors");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/mrstci/mrstov5630/ov5630.h b/drivers/media/video/mrstci/mrstov5630/ov5630.h
new file mode 100644
index 0000000..3da0ecd
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630/ov5630.h
@@ -0,0 +1,672 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#define I2C_OV5630	0x6C
+/* Should add to kernel source */
+#define I2C_DRIVERID_OV5630	1046
+/* GPIO pin on Moorestown */
+#define GPIO_SCLK_25	44
+#define GPIO_STB_PIN	47
+#define GPIO_STDBY_PIN	49
+#define GPIO_RESET_PIN	50
+
+/* System control register */
+#define OV5630_AGC 		0x3000
+#define OV5630_AGCS 	0x3001
+#define OV5630_AEC_H	0x3002
+#define OV5630_AEC_L  	0x3003
+#define OV5630_LAEC_H 	0x3004
+#define OV5630_LAEC_L 	0x3005
+#define OV5630_AECS_H	0x3008
+#define OV5630_AECS_L	0x3009
+#define OV5630_PID_H	0x300A
+#define OV5630_PID_L	0x300B
+#define OV5630_SCCB_ID		0x300C
+#define OV5630_PLL_1	0x300E
+#define OV5630_PLL_2	0x300F
+#define OV5630_PLL_3	0x3010
+#define OV5630_PLL_4		0x3011
+#define OV5630_SYS		0x3012
+#define OV5630_AUTO_1	0x3013
+#define OV5630_AUTO_2	0x3014
+#define OV5630_AUTO_3	0x3015
+#define OV5630_AUTO_4	0x3016
+#define OV5630_AUTO_5	0x3017
+#define OV5630_WPT		0x3018
+#define OV5630_BPT		0x3019
+#define OV5630_VPT		0x301A
+#define OV5630_YAVG		0x301B
+#define OV5630_AECG_50	0x301C
+#define OV5630_AECG_60	0x301D
+#define OV5630_ADDVS_H	0x301E
+#define OV5630_ADDVS_L	0x301F
+#define OV5630_FRAME_LENGTH_LINES_H	0x3020
+#define OV5630_FRAME_LENGTH_LINES_L	0x3021
+#define OV5630_LINE_LENGTH_PCK_H	0x3022
+#define OV5630_LINE_LENGTH_PCK_L	0x3023
+#define OV5630_X_ADDR_START_H	0x3024
+#define OV5630_X_ADDR_START_L	0x3025
+#define OV5630_Y_ADDR_START_H	0x3026
+#define OV5630_Y_ADDR_START_L	0x3027
+#define OV5630_X_ADDR_END_H	0x3028
+#define OV5630_X_ADDR_END_L	0x3029
+#define OV5630_Y_ADDR_END_H	0x302A
+#define OV5630_Y_ADDR_END_L	0x302B
+#define OV5630_X_OUTPUT_SIZE_H	0x302C
+#define OV5630_X_OUTPUT_SIZE_L	0x302D
+#define OV5630_Y_OUTPUT_SIZE_H	0x302E
+#define OV5630_Y_OUTPUT_SIZE_L	0x302F
+#define OV5630_FRAME_CNT	0x3030
+#define OV5630_DATR_LMO_0	0x3038
+#define OV5630_DATR_LMO_1	0x3039
+#define OV5630_DATR_LMO_2	0x303A
+#define OV5630_DATR_D56	0x303D
+#define OV5630_DATR_EF	0x303E
+#define OV5630_R_SIGMA_0	0x3048
+#define OV5630_R_SIGMA_1	0x3049
+#define OV5630_R_SIGMA_2	0x304A
+#define OV5630_R_SIGMA_3	0x304B
+#define OV5630_R_SIGMA_4	0x304C
+#define OV5630_R_SIGMA_5	0x304D
+#define OV5630_D56COM	0x304E
+#define OV5630_5060TH	0x3050
+#define OV5630_LMO_TH1	0x3058
+#define OV5630_LMO_TH2	0x3059
+#define OV5630_LMO_K	0x305A
+#define OV5630_BD50ST_H	0x305C
+#define OV5630_BD50ST_L	0x305D
+#define OV5630_BD60ST_H	0x305E
+#define OV5630_BD60ST_L	0x305F
+#define OV5630_HSYNST	0x306D
+#define OV5630_HSYNED	0x306E
+#define OV5630_HSYNED_HSYNST	0x306F
+#define OV5630_TMC_RWIN0	0x3070
+#define OV5630_IO_CTRL0	0x30B0
+#define OV5630_IO_CTRL1	0x30B1
+#define OV5630_IO_CTRL2	0x30B2
+#define OV5630_DSIO_0	0x30B3
+#define OV5630_DSIO_1	0x30B4
+#define OV5630_DSIO_2	0x30B5
+#define OV5630_TMC_10	0x30B6
+#define OV5630_TMC_12	0x30B7
+#define OV5630_TMC_14	0x30B9
+#define OV5630_TMC_COM4	0x30BA
+#define OV5630_TMC_REG6C	0x30BB
+#define OV5630_TMC_REG6E	0x30BC
+#define OV5630_R_CLK_S	0x30BD
+#define OV5630_R_CLK_A	0x30BE
+#define OV5630_R_CLK_A1	0x30BF
+#define OV5630_FRS_0	0x30E0
+#define OV5630_FRS_1	0x30E1
+#define OV5630_FRS_2	0x30E2
+#define OV5630_FRS_3	0x30E3
+#define OV5630_FRS_FECNT	0x30E4
+#define OV5630_FRS_FECNT_0	0x30E5
+#define OV5630_FRS_FECNT_1	0x30E6
+#define OV5630_FRS_RFRM	0x30E7
+#define OV5630_FRS_RSTRB	0x30E8
+#define OV5630_SA1TMC	0x30E9
+#define OV5630_TMC_MISC0	0x30EA
+#define OV5630_TMC_MISC1	0x30EB
+#define OV5630_FLEX_TXP	0x30F0
+#define OV5630_FLEX_FLT	0x30F1
+#define OV5630_FLEX_TXT	0x30F2
+#define OV5630_FLEX_HBK	0x30F3
+#define OV5630_FLEX_HSG	0x30F4
+#define OV5630_FLEX_SA1SFT	0x30F5
+#define OV5630_RVSOPT	0x30F6
+#define OV5630_AUTO	0x30F7
+#define OV5630_IMAGE_TRANSFORM	0x30F8
+#define OV5630_IMAGE_LUM	0x30F9
+#define OV5630_IMAGE_SYSTEM	0x30FA
+#define OV5630_GROUP_WR	0x30FF
+
+/* CIF control register */
+#define OV5630_CIF_CTRL2	0x3202
+
+/* ISP control register */
+#define OV5630_ISP_CTL00	0x3300
+#define OV5630_ISP_CTL01	0x3301
+#define OV5630_ISP_CTL02	0x3302
+#define OV5630_ISP_03	0x3303
+#define OV5630_ISP_DIG_GAIN_MAN	0x3304
+#define OV5630_ISP_BIAS_MAN	0x3305
+#define OV5630_ISP_06	0x3306
+#define OV5630_ISP_STABLE_RANGE	0x3307
+#define OV5630_ISP_R_GAIN_MAN_1	0x3308
+#define OV5630_ISP_R_GAIN_MAN_0	0x3309
+#define OV5630_ISP_G_GAIN_MAN_1	0x330A
+#define OV5630_ISP_G_GAIN_MAN_0	0x330B
+#define OV5630_ISP_B_GAIN_MAN_1	0x330C
+#define OV5630_ISP_B_GAIN_MAN_0	0x330D
+#define OV5630_ISP_STABLE_RANGEW	0x330E
+#define OV5630_ISP_AWB_FRAME_CNT	0x330F
+#define OV5630_ISP_11	0x3311
+#define OV5630_ISP_12	0x3312
+#define OV5630_ISP_13	0x3313
+#define OV5630_ISP_HSIZE_IN_1	0x3314
+#define OV5630_ISP_HSIZE_IN_0	0x3315
+#define OV5630_ISP_VSIZE_IN_1	0x3316
+#define OV5630_ISP_VSIZE_IN_0	0x3317
+#define OV5630_ISP_18	0x3318
+#define OV5630_ISP_19	0x3319
+#define OV5630_ISP_EVEN_MAN0	0x331A
+#define OV5630_ISP_EVEN_MAN1	0x331B
+#define OV5630_ISP_EVEN_MAN2	0x331C
+#define OV5630_ISP_EVEN_MAN3	0x331D
+#define OV5630_ISP_1E	0x331E
+#define OV5630_ISP_1F	0x331F
+#define OV5630_ISP_BLC_LMT_OPTION	0x3320
+#define OV5630_ISP_BLC_THRE	0x3321
+#define OV5630_ISP_22	0x3322
+#define OV5630_ISP_23	0x3323
+#define OV5630_ISP_BLC_MAN0_1	0x3324
+#define OV5630_ISP_BLC_MAN0_0	0x3325
+#define OV5630_ISP_BLC_MAN1_1	0x3326
+#define OV5630_ISP_BLC_MAN1_0	0x3327
+#define OV5630_ISP_BLC_MAN2_1	0x3328
+#define OV5630_ISP_BLC_MAN2_0	0x3329
+#define OV5630_ISP_BLC_MAN3_1	0x332A
+#define OV5630_ISP_BLC_MAN3_0	0x332B
+#define OV5630_ISP_BLC_MAN4_1	0x332C
+#define OV5630_ISP_BLC_MAN4_0	0x332D
+#define OV5630_ISP_BLC_MAN5_1	0x332E
+#define OV5630_ISP_BLC_MAN5_0	0x332F
+#define OV5630_ISP_BLC_MAN6_1	0x3330
+#define OV5630_ISP_BLC_MAN6_0	0x3331
+#define OV5630_ISP_BLC_MAN7_1	0x3332
+#define OV5630_ISP_BLC_MAN7_0	0x3333
+#define OV5630_ISP_CD	0x33CD
+#define OV5630_ISP_FF	0x33FF
+
+/* clipping control register */
+#define OV5630_CLIP_CTRL0	0x3400
+#define OV5630_CLIP_CTRL1	0x3401
+#define OV5630_CLIP_CTRL2	0x3402
+#define OV5630_CLIP_CTRL3	0x3403
+#define OV5630_CLIP_CTRL4	0x3404
+#define OV5630_CLIP_CTRL5	0x3405
+#define OV5630_CLIP_CTRL6	0x3406
+#define OV5630_CLIP_CTRL7	0x3407
+
+/* DVP control register */
+#define OV5630_DVP_CTRL00	0x3500
+#define OV5630_DVP_CTRL01	0x3501
+#define OV5630_DVP_CTRL02	0x3502
+#define OV5630_DVP_CTRL03	0x3503
+#define OV5630_DVP_CTRL04	0x3504
+#define OV5630_DVP_CTRL05	0x3505
+#define OV5630_DVP_CTRL06	0x3506
+#define OV5630_DVP_CTRL07	0x3507
+#define OV5630_DVP_CTRL08	0x3508
+#define OV5630_DVP_CTRL09	0x3509
+#define OV5630_DVP_CTRL0A	0x350A
+#define OV5630_DVP_CTRL0B	0x350B
+#define OV5630_DVP_CTRL0C	0x350C
+#define OV5630_DVP_CTRL0D	0x350D
+#define OV5630_DVP_CTRL0E	0x350E
+#define OV5630_DVP_CTRL0F	0x350F
+#define OV5630_DVP_CTRL10	0x3510
+#define OV5630_DVP_CTRL11	0x3511
+#define OV5630_DVP_CTRL12	0x3512
+#define OV5630_DVP_CTRL13	0x3513
+#define OV5630_DVP_CTRL14	0x3514
+#define OV5630_DVP_CTRL15	0x3515
+#define OV5630_DVP_CTRL16	0x3516
+#define OV5630_DVP_CTRL17	0x3517
+#define OV5630_DVP_CTRL18	0x3518
+#define OV5630_DVP_CTRL19	0x3519
+#define OV5630_DVP_CTRL1A	0x351A
+#define OV5630_DVP_CTRL1B	0x351B
+#define OV5630_DVP_CTRL1C	0x351C
+#define OV5630_DVP_CTRL1D	0x351D
+#define OV5630_DVP_CTRL1E	0x351E
+#define OV5630_DVP_CTRL1F	0x351F
+
+/* MIPI control register */
+#define OV5630_MIPI_CTRL00	0x3600
+#define OV5630_MIPI_CTRL01	0x3601
+#define OV5630_MIPI_CTRL02	0x3602
+#define OV5630_MIPI_CTRL03	0x3603
+#define OV5630_MIPI_CTRL04	0x3604
+#define OV5630_MIPI_CTRL05	0x3605
+#define OV5630_MIPI_CTRL06	0x3606
+#define OV5630_MIPI_CTRL07	0x3607
+#define OV5630_MIPI_CTRL08	0x3608
+#define OV5630_MIPI_CTRL09	0x3609
+#define OV5630_MIPI_CTRL0A	0x360A
+#define OV5630_MIPI_CTRL0B	0x360B
+#define OV5630_MIPI_CTRL0C	0x360C
+#define OV5630_MIPI_CTRL0D	0x360D
+#define OV5630_MIPI_CTRL0E	0x360E
+#define OV5630_MIPI_CTRL0F	0x360F
+#define OV5630_MIPI_CTRL10	0x3610
+#define OV5630_MIPI_CTRL11	0x3611
+#define OV5630_MIPI_CTRL12	0x3612
+#define OV5630_MIPI_CTRL13	0x3613
+#define OV5630_MIPI_CTRL14	0x3614
+#define OV5630_MIPI_CTRL15	0x3615
+#define OV5630_MIPI_CTRL16	0x3616
+#define OV5630_MIPI_CTRL17	0x3617
+#define OV5630_MIPI_CTRL18	0x3618
+#define OV5630_MIPI_CTRL19	0x3619
+#define OV5630_MIPI_CTRL1A	0x361A
+#define OV5630_MIPI_CTRL1B	0x361B
+#define OV5630_MIPI_CTRL1C	0x361C
+#define OV5630_MIPI_CTRL1D	0x361D
+#define OV5630_MIPI_CTRL1E	0x361E
+#define OV5630_MIPI_CTRL1F	0x361F
+#define OV5630_MIPI_CTRL20	0x3620
+#define OV5630_MIPI_CTRL21	0x3621
+#define OV5630_MIPI_CTRL22	0x3622
+#define OV5630_MIPI_CTRL23	0x3623
+#define OV5630_MIPI_CTRL24	0x3624
+#define OV5630_MIPI_CTRL25	0x3625
+#define OV5630_MIPI_CTRL26	0x3626
+#define OV5630_MIPI_CTRL27	0x3627
+#define OV5630_MIPI_CTRL28	0x3628
+#define OV5630_MIPI_CTRL29	0x3629
+#define OV5630_MIPI_CTRL2A	0x362A
+#define OV5630_MIPI_CTRL2B	0x362B
+#define OV5630_MIPI_CTRL2C	0x362C
+#define OV5630_MIPI_CTRL2D	0x362D
+#define OV5630_MIPI_CTRL2E	0x362E
+#define OV5630_MIPI_CTRL2F	0x362F
+#define OV5630_MIPI_CTRL30	0x3630
+#define OV5630_MIPI_CTRL31	0x3631
+#define OV5630_MIPI_CTRL32	0x3632
+#define OV5630_MIPI_CTRL33	0x3633
+#define OV5630_MIPI_CTRL34	0x3634
+#define OV5630_MIPI_CTRL35	0x3635
+#define OV5630_MIPI_CTRL36	0x3636
+#define OV5630_MIPI_CTRL37	0x3637
+#define OV5630_MIPI_CTRL38	0x3638
+#define OV5630_MIPI_CTRL39	0x3639
+#define OV5630_MIPI_CTRL3A	0x363A
+#define OV5630_MIPI_CTRL3B	0x363B
+#define OV5630_MIPI_CTRL3C	0x363C
+#define OV5630_MIPI_CTRL3D	0x363D
+#define OV5630_MIPI_CTRL3E	0x363E
+#define OV5630_MIPI_CTRL3F	0x363F
+#define OV5630_MIPI_RO61	0x3661
+#define OV5630_MIPI_RO62	0x3662
+#define OV5630_MIPI_RO63	0x3663
+#define OV5630_MIPI_RO64	0x3664
+#define OV5630_MIPI_RO65	0x3665
+#define OV5630_MIPI_RO66	0x3666
+
+/* General definition for ov5630 */
+#define OV5630_OUTWND_MAX_H		QSXXGA_PLUS4_SIZE_H
+#define OV5630_OUTWND_MAX_V		QSXGA_PLUS4_SIZE_V
+
+struct regval_list {
+	u16 reg_num;
+	u8 value;
+};
+
+/*
+ * Default register value
+ * 5Mega Pixel, 2592x1944
+ */
+static struct regval_list ov5630_def_reg[] = {
+	{0x300f, 0x00}, /*00*/
+	{0x30b2, 0x32},
+	{0x3084, 0x44},
+	{0x3016, 0x01},
+	{0x308a, 0x25},
+
+	{0x3013, 0xff},
+	{0x3015, 0x03},
+	{0x30bf, 0x02},
+
+	{0x3065, 0x50},
+	{0x3068, 0x08},
+	{0x30ac, 0x05},
+	{0x309e, 0x24},
+	{0x3091, 0x04},
+
+	{0x3075, 0x22},
+	{0x3076, 0x23},
+	{0x3077, 0x24},
+	{0x3078, 0x25},
+
+	{0x30b5, 0x0c},
+	{0x3090, 0x67},
+
+	{0x30f9, 0x11},
+	{0x3311, 0x80},
+	{0x3312, 0x1f},
+
+	{0x3103, 0x10},
+	{0x305c, 0x01},
+	{0x305d, 0x29},
+	{0x305e, 0x00},
+	{0x305f, 0xf7},
+	{0x308d, 0x0b},
+	{0x30ad, 0x20},
+	{0x3072, 0x0d},
+	{0x308b, 0x82},
+	{0x3317, 0x9c},
+	{0x3318, 0x22},
+	{0x3025, 0x20},
+	{0x3027, 0x08},
+	{0x3029, 0x3f},
+	{0x302b, 0xa3},
+	{0x3319, 0x22},
+	{0x30a1, 0xc4},
+	{0x306a, 0x05},
+	{0x3315, 0x22},
+	{0x30ae, 0x25},
+	{0x3304, 0x40},
+	{0x3099, 0x49},
+
+	{0x300e, 0xb1/*b0*/}, /* Note this PLL setting*/
+	{0x300f, 0x10}, /*00*/
+	{0x3010, 0x07}, /*change from 0f according to SV */
+	{0x3011, 0x40},
+	{0x30af, 0x10},
+	{0x304a, 0x00},
+	{0x304d, 0x00},
+
+	{0x304e, 0x22},
+	{0x304d, 0xa0},
+	{0x3058, 0x00},
+	{0x3059, 0xff},
+	{0x305a, 0x00},
+
+	{0x30e9, 0x04},
+	{0x3084, 0x44},
+	{0x3090, 0x67},
+	{0x30e9, 0x04},
+
+	{0x30b5, 0x1c},
+	{0x331f, 0x22},
+	{0x30ae, 0x15},
+	{0x3304, 0x4c},
+
+	{0x3300, 0xfb},
+	{0x3071, 0x34},
+	{0x30e7, 0x01},
+	{0x3302, 0x60},
+	{0x331e, 0x05},
+	{0x3321, 0x04},
+
+	/* Mark end */
+	{0xffff, 0xff},
+
+};
+
+/* MIPI register are removed by Wen */
+
+/* 2592x1944 */
+static struct regval_list ov5630_res_qsxga_plus4[] = {
+	{0x3020, 0x07},
+	{0x3021, 0xbc},
+	{0x3022, 0x0c/*0a*/},
+	{0x3023, 0xa0/*00*/},
+	{0x305c, 0x01},
+	{0x305d, 0x29},
+	{0x305e, 0x00},
+	{0x305f, 0xf7},
+
+	/* 30fps , 96 MHZ*/
+	/* {0x300f, 0x10}, */
+	{0x300f, 0x10},
+	{0x300e, 0xb1},
+	/* mipi */
+#ifdef MIPI
+	{0x30b0, 0x00},
+	{0x30b1, 0xfc},
+	{0x3603, 0x50},
+	{0x3601, 0x0F},
+	/* lan2 bit 10*/
+	{0x3010, 0x07},
+	{0x30fa, 0x01},
+	/* {0x 30f8 09 */
+	{0x3096, 0x50},
+	/* end mipi*/
+#else
+	/* parrral */
+	{0x30fa, 0x01},
+#endif
+	/* end post*/
+	{0xffff, 0xff},
+};
+
+/* 1920x1080 */
+static struct regval_list ov5630_res_1080p[] = {
+	/*res start*/
+	{0x3020, 0x04},
+	{0x3021, 0x5c},
+	{0x3022, 0x0b/*0a*/},
+	{0x3023, 0x32/*00*/},
+	{0x305c, 0x01},
+	{0x305d, 0x2c},
+	{0x3024, 0x01},
+	{0x3025, 0x6e/*70*/},
+	{0x3026, 0x01},
+	{0x3027, 0xb8},
+	{0x3028, 0x08},
+	{0x3029, 0xef},
+	{0x302a, 0x05},
+	{0x302b, 0xf3},
+	{0x302c, 0x07},
+	{0x302d, 0x80},
+	{0x302e, 0x04},
+	{0x302f, 0x38},
+	{0x3314, 0x07},
+	{0x3315, 0x82/*80*/},
+	{0x3316, 0x04},
+	{0x3317, 0x3c},
+
+	/* 30fps , 96 MHZ*/
+	{0x300f, 0x10}, /* 00 */
+	{0x300e, 0xb1},
+
+	/* mipi */
+#ifdef MIPI
+	{0x30b0, 0x00},
+	{0x30b1, 0xfc},
+	{0x3603, 0x50},
+	{0x3601, 0x0F},
+	/* lan2 bit 10*/
+	{0x3010, 0x07},
+	{0x30fa, 0x01},
+	/* {0x 30f8 09 */
+	{0x3096, 0x50},
+	/* end mipi*/
+#else
+	/* parrral */
+	{0x30fa, 0x01},
+#endif
+	/* end post*/
+	{0xffff, 0xff},
+};
+
+/* 1280x960 V1F2_H1F2 */
+static struct regval_list ov5630_res_xga_plus[] = {
+	{0x3020, 0x03},
+	{0x3021, 0xe4},
+	{0x3022, 0x0c/*07*/},
+	{0x3023, 0x8c/*76*/},
+	{0x305c, 0x00},
+	{0x305d, 0xb1},
+	{0x3024, 0x00},
+	{0x3025, 0x30},
+	{0x3026, 0x00},
+	{0x3027, 0x10/*14*/},
+	{0x3028, 0x0a},
+	{0x3029, 0x2f},
+	{0x302a, 0x07},
+	{0x302b, 0xa7/*a7*/},
+	{0x302c, 0x05},
+	{0x302d, 0x00},
+	{0x302e, 0x03},
+	{0x302f, 0xc0},
+
+	{0x30f8, 0x05},
+	{0x30f9, 0x13},
+	{0x3314, 0x05},
+	{0x3315, 0x02/*00*/},
+	{0x3316, 0x03},
+	{0x3317, 0xc4},
+
+	{0x300f, 0x10}, /* 00 */
+	{0x300e, 0xb1},
+
+#ifdef MIPI
+	{0x30b0, 0x00},
+	{0x30b1, 0xfc},
+	{0x3603, 0x50},
+	{0x3601, 0x0F},
+	/* lan2 bit 10*/
+	{0x3010, 0x07},
+	{0x30fa, 0x01},
+	/* {0x 30f8 09 */
+	{0x3096, 0x50},
+	/* end mipi*/
+#else
+	/* parrral */
+	{0x30fa, 0x01},
+#endif
+
+	{0xffff, 0xff},
+};
+
+/* 1280x720, V1F2 & H1F2 */
+static struct regval_list ov5630_res_720p[] = {
+	{0x3020, 0x02},
+	{0x3021, 0xf4},
+	{0x3022, 0x07},
+	{0x3023, 0x80},
+	{0x305c, 0x00},
+	{0x305d, 0xff},
+	{0x305e, 0x00},
+	{0x305f, 0xd4},
+
+	/* Crop then downscale */
+	{0x3024, 0x00},
+	{0x3025, 0x2c},
+	{0x3026, 0x00},
+	{0x3027, 0xf0},
+	{0x3028, 0x0a},
+	{0x3029, 0x2f},
+	{0x302a, 0x08},
+	{0x302b, 0x97},
+
+	{0x30f8, 0x05},
+
+	{0x302c, 0x05},
+	{0x302d, 0x00},
+	{0x302e, 0x02},
+	{0x302f, 0xd0},
+
+	{0x30f9, 0x13},
+	{0x3314, 0x05},
+	{0x3315, 0x04},
+	{0x3316, 0x02},
+	{0x3317, 0xd4},
+
+	/* Add this to test setting from OVT */
+	{0x300f, 0x10}, /*00*/
+	{0x300e, 0xb0},
+
+#ifdef MIPI
+	{0x30b0, 0x00},
+	{0x30b1, 0xfc},
+	{0x3603, 0x50},
+	{0x3601, 0x0F},
+	/* lan2 bit 10*/
+	{0x3010, 0x07},
+	{0x30fa, 0x01},
+	/* {0x 30f8 09 */
+	{0x3096, 0x50},
+	/* end mipi*/
+#else
+	/* parrral */
+	{0x30fa, 0x01},
+#endif
+
+	{0xffff, 0xff},
+};
+
+/*VGA 40fps now*/
+static struct regval_list ov5630_res_vga_ac04_bill[] = {
+	/* res setting*/
+	{0x3020, 0x02},
+	{0x3021, 0x04},
+	{0x3022, 0x08},
+	{0x3023, 0x48},
+	{0x305c, 0x00},
+	{0x305d, 0x5e},
+	{0x3024, 0x00},
+	{0x3025, 0x2c},/*2c*/
+	{0x3026, 0x00},
+	{0x3027, 0x14},
+	{0x3028, 0x0a},
+	{0x3029, 0x2f},
+	{0x302a, 0x07},
+	{0x302b, 0xa3},
+	{0x302c, 0x02},
+	{0x302d, 0x80},
+	{0x302e, 0x01},
+	{0x302f, 0xe0},
+
+	{0x30b3, 0x09},
+	{0x3301, 0xc1},
+	{0x3313, 0xf1},
+	{0x3314, 0x05},
+	{0x3315, 0x04},/*04*/
+	{0x3316, 0x01},
+	{0x3317, 0xe4},
+	{0x3318, 0x20},
+
+	{0x300f, 0x10/*00*/},
+	{0x30f8, 0x09},
+
+	{0x300f, 0x11},
+	{0x300e, 0xb2},
+
+	{0x3015, 0x02},
+	/* mipi */
+#ifdef MIPI
+	{0x30b0, 0x00},
+	{0x30b1, 0xfc},
+	{0x3603, 0x50},
+	{0x3601, 0x0F},
+	/* lan2 bit 10*/
+	{0x3010, 0x07},
+	{0x30fa, 0x01},
+	/* {0x 30f8 09 */
+	{0x3096, 0x50},
+	/* end mipi*/
+#else
+
+	/* parrral */
+	{0x30fa, 0x01},
+	{0x30f8, 0x09},
+	{0x3096, 0x50},
+#endif
+
+	{0xffff, 0xff},
+};
diff --git a/drivers/media/video/mrstci/mrstov5630_motor/Kconfig b/drivers/media/video/mrstci/mrstov5630_motor/Kconfig
new file mode 100644
index 0000000..b6dcf62
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630_motor/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_MRST_OV5630_MOTOR
+	tristate "Moorestown OV5630 motor"
+	depends on I2C && VIDEO_MRST_ISP && VIDEO_MRST_OV5630
+
+	---help---
+	  Say Y here if your platform support OV5630 motor
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mrstov2650.ko.
diff --git a/drivers/media/video/mrstci/mrstov5630_motor/Makefile b/drivers/media/video/mrstci/mrstov5630_motor/Makefile
new file mode 100644
index 0000000..056b2a6
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630_motor/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_MRST_OV2650)	 += mrstov5630_motor.o
+
+EXTRA_CFLAGS	+=	-I$(src)/../include
diff --git a/drivers/media/video/mrstci/mrstov5630_motor/mrstov5630_motor.c b/drivers/media/video/mrstci/mrstov5630_motor/mrstov5630_motor.c
new file mode 100644
index 0000000..1bb7274
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630_motor/mrstov5630_motor.c
@@ -0,0 +1,428 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
+
+#include "ov5630_motor.h"
+
+/* #define OSPM */
+#include <asm/ipc_defs.h>
+#define PMIC_WRITE1(ipcbuf, reg1, val1) \
+	do { \
+		memset(&ipcbuf, 0, sizeof(struct ipc_pmic_reg_data)); \
+		ipcbuf.ioc = 0; \
+		ipcbuf.num_entries = 1; \
+		ipcbuf.pmic_reg_data[0].register_address = reg1; \
+		ipcbuf.pmic_reg_data[0].value = val1; \
+		if (ipc_pmic_register_write(&ipcbuf, 1) != 0) { \
+			return -1; \
+		} \
+	} while (0);
+
+static int mrstov5630_motor_debug;
+module_param(mrstov5630_motor_debug, int, 0644);
+MODULE_PARM_DESC(mrstov5630_motor_debug, "Debug level (0-1)");
+
+#define dprintk(level, fmt, arg...) do {			\
+	if (mrstov5630_motor_debug >= level) 				\
+		printk(KERN_DEBUG "mrstisp@%s: " fmt "\n", \
+		       __func__, ## arg); } \
+	while (0)
+
+#define eprintk(fmt, arg...)	\
+	printk(KERN_ERR "mrstisp@%s: line %d: " fmt "\n",	\
+	       __func__, __LINE__, ## arg);
+
+#define DBG_entering	dprintk(2, "entering");
+#define DBG_leaving	dprintk(2, "leaving");
+#define DBG_line	dprintk(2, " line: %d", __LINE__);
+
+static inline struct ov5630_motor *to_motor_config(struct v4l2_subdev *sd)
+{
+	return container_of(sd, struct ov5630_motor, sd);
+}
+
+static int motor_read(struct i2c_client *c, u16 *reg)
+{
+	int ret;
+	struct i2c_msg msg;
+	u8 msgbuf[2];
+
+	/* Read needs two message to go */
+	msgbuf[0] = 0;
+	msgbuf[1] = 0;
+
+	memset(&msg, 0, sizeof(msg));
+	msg.addr = c->addr;
+	msg.buf = msgbuf;
+	msg.len = 2;
+	msg.flags = I2C_M_RD;
+
+	ret = i2c_transfer(c->adapter, &msg, 1);
+
+	*reg = (msgbuf[0] << 8 | msgbuf[1]);
+
+	ret = (ret == 1) ? 0 : -1;
+	return ret;
+}
+
+static int motor_write(struct i2c_client *c, u16 reg)
+{
+	int ret;
+	struct i2c_msg msg;
+	u8 msgbuf[2];
+
+	/* Writing only needs one message */
+	memset(&msg, 0, sizeof(msg));
+	msgbuf[0] = reg >> 8;
+	msgbuf[1] = reg;
+
+	msg.addr = c->addr;
+	msg.flags = 0;
+	msg.buf = msgbuf;
+	msg.len = 2;
+
+	ret = i2c_transfer(c->adapter, &msg, 1);
+
+	ret = (ret == 1) ? 0 : -1;
+	return ret;
+}
+
+static int ov5630_motor_goto_position(struct i2c_client *c,
+				      unsigned short code,
+				      struct ov5630_motor *config)
+{
+	int max_code, min_code;
+	u8 cmdh, cmdl;
+	u16 cmd, val = 0;
+
+	max_code = config->macro_code;
+	min_code = config->infin_code;
+
+	if (code > max_code)
+		code = max_code;
+	if (code < min_code)
+		code = min_code;
+
+	cmdh = (MOTOR_DAC_CODE_H(code));
+	cmdl = (MOTOR_DAC_CODE_L(code) | MOTOR_DAC_CTRL_MODE_2(SUB_MODE_4));
+	cmd = cmdh << 8 | cmdl;
+
+	motor_write(c, cmd);
+	/*Delay more than full-scale transition time 8.8ms*/
+	msleep(8);
+	motor_read(c, &val);
+
+	return (cmd == val ? 0 : -1);
+}
+
+int ov5630_motor_wakeup(void)
+{
+	return gpio_direction_output(GPIO_AF_PD, 1);
+}
+
+int ov5630_motor_standby(void)
+{
+	return gpio_direction_output(GPIO_AF_PD, 0);
+}
+
+int ov5630_motor_init(struct i2c_client *client, struct ov5630_motor *config)
+{
+	int ret;
+	int infin_cur, macro_cur;
+#ifdef OSPM
+	/* Power on motor */
+	struct ipc_pmic_reg_data ipcbuf;
+
+	PMIC_WRITE1(ipcbuf, 0x50, 0x27);
+	printk(KERN_WARNING "Power on Vcc33 for motor\n");
+#endif
+
+	infin_cur = MAX(MOTOR_INFIN_CUR, MOTOR_DAC_MIN_CUR);
+	macro_cur = MIN(MOTOR_MACRO_CUR, MOTOR_DAC_MAX_CUR);
+
+	config->infin_cur = infin_cur;
+	config->macro_cur = macro_cur;
+
+	config->infin_code = (int)((infin_cur * MOTOR_DAC_MAX_CODE)
+				   / MOTOR_DAC_MAX_CUR);
+	config->macro_code = (int)((macro_cur * MOTOR_DAC_MAX_CODE)
+				   / MOTOR_DAC_MAX_CUR);
+
+	config->max_step = ((config->macro_code - config->infin_code)
+			    >> MOTOR_STEP_SHIFT) + 1;
+	/* Note here, maybe macro_code */
+	ret = ov5630_motor_goto_position(client, config->infin_code, config);
+	if (!ret)
+		config->cur_code = config->infin_code;
+	else
+		printk(KERN_ERR "Error while initializing motor\n");
+
+	return ret;
+}
+
+int ov5630_motor_set_focus(struct i2c_client *c, int step,
+			   struct ov5630_motor *config)
+{
+	int s_code, ret;
+	int max_step = config->max_step;
+	unsigned int val = step;
+
+	DBG_entering;
+	dprintk(1, "setting setp %d", step);
+	if (val > max_step)
+		val = max_step;
+
+	s_code = (val << MOTOR_STEP_SHIFT);
+	s_code += config->infin_code;
+
+	ret = ov5630_motor_goto_position(c, s_code, config);
+	if (!ret)
+		config->cur_code = s_code;
+
+	DBG_leaving;
+	return ret;
+}
+
+static int ov5630_motor_s_ctrl(struct v4l2_subdev *sd,
+			       struct v4l2_control *ctrl)
+{
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	struct ov5630_motor *config = to_motor_config(sd);
+	int ret;
+
+	DBG_entering;
+	ret = ov5630_motor_set_focus(c, ctrl->value, config);
+	if (ret) {
+		eprintk("error call ov5630_motor_set_focue");
+		return ret;
+	}
+	DBG_leaving;
+	return 0;
+}
+int ov5630_motor_get_focus(struct i2c_client *c, unsigned int *step,
+			   struct ov5630_motor *config)
+{
+	int ret_step;
+
+	ret_step = ((config->cur_code - config->infin_code)
+		    >> MOTOR_STEP_SHIFT);
+
+	if (ret_step <= config->max_step)
+		*step = ret_step;
+	else
+		*step = config->max_step;
+
+	return 0;
+}
+
+static int ov5630_motor_g_ctrl(struct v4l2_subdev *sd,
+			       struct v4l2_control *ctrl)
+{
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	struct ov5630_motor *config = to_motor_config(sd);
+	int ret;
+
+	DBG_entering;
+	dprintk(2, "c = %p, config = %p, ctrl = %p", c, config, ctrl);
+	ret = ov5630_motor_get_focus(c, &ctrl->value, config);
+	if (ret) {
+		eprintk("error call ov5630_motor_get_focue");
+		return ret;
+	}
+	DBG_leaving;
+	return 0;
+}
+int ov5630_motor_max_step(struct i2c_client *c, unsigned int *max_code,
+			   struct ov5630_motor *config)
+{
+	if (config->max_step != 0)
+		*max_code = config->max_step;
+	return 0;
+}
+
+static int ov5630_motor_queryctrl(struct v4l2_subdev *sd,
+			    struct v4l2_queryctrl *qc)
+{
+	struct ov5630_motor *config = to_motor_config(sd);
+
+	DBG_entering;
+
+	if (qc->id != V4L2_CID_FOCUS_ABSOLUTE)
+		return -EINVAL;
+
+	dprintk(1, "got focus range of %d", config->max_step);
+	if (config->max_step != 0)
+		qc->maximum = config->max_step;
+	DBG_leaving;
+	return 0;
+}
+static const struct v4l2_subdev_core_ops ov5630_motor_core_ops = {
+	/*
+	.queryctrl = ov5630_queryctrl,
+	.g_ctrl = ov5630_g_ctrl,
+	*/
+	.g_ctrl = ov5630_motor_g_ctrl,
+	.s_ctrl = ov5630_motor_s_ctrl,
+	.queryctrl = ov5630_motor_queryctrl,
+};
+
+static const struct v4l2_subdev_ops ov5630_motor_ops = {
+	.core = &ov5630_motor_core_ops,
+};
+
+static int ov5630_motor_detect(struct i2c_client *client)
+{
+	struct i2c_adapter *adapter = client->adapter;
+	int adap_id = i2c_adapter_id(adapter);
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
+		eprintk("error i2c check func");
+		return -ENODEV;
+	}
+
+	if (adap_id != 1) {
+		eprintk("adap_id != 1");
+		return -ENODEV;
+	}
+
+	/* if (ov5630_motor_wakeup()) */
+		/* return -ENODEV; */
+	ov5630_motor_wakeup();
+	ssleep(1);
+
+	/*
+	ov5630_motor_read(client, (u32)OV5630_PID_H, &value);
+	if ((u8)value != 0x56) {
+		eprintk("PID != 0x56, but %x", value);
+		dprintk(2, "client->addr = %x", client->addr);
+		return -ENODEV;
+	}
+	*/
+
+	return 0;
+}
+
+static int ov5630_motor_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	struct ov5630_motor *info;
+	struct v4l2_subdev *sd;
+	int ret = -1;
+/* 	struct i2c_client *motor; */
+
+	DBG_entering;
+	v4l_info(client, "chip found @ 0x%x (%s)\n",
+		 client->addr << 1, client->adapter->name);
+	/*
+	 * Setup sensor configuration structure
+	 */
+	info = kzalloc(sizeof(struct ov5630_motor), GFP_KERNEL);
+	if (!info) {
+		eprintk("fail to malloc for ci_motor");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = ov5630_motor_detect(client);
+	if (ret) {
+		eprintk("error ov5630_motor_detect");
+		goto out_free;
+	}
+
+	sd = &info->sd;
+	v4l2_i2c_subdev_init(sd, client, &ov5630_motor_ops);
+
+	/*
+	 * Initialization OV5630
+	 * then turn into standby mode
+	 */
+	/* ret = ov5630_motor_standby(); */
+	ret = ov5630_motor_init(client, info);
+	if (ret) {
+		eprintk("error calling ov5630_motor_init");
+		goto out_free;
+	}
+
+	ret = 0;
+	goto out;
+
+out_free:
+	kfree(info);
+	DBG_leaving;
+out:
+	return ret;
+}
+
+/*
+ * XXX: Need to be checked
+ */
+static int ov5630_motor_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+	DBG_entering;
+
+	v4l2_device_unregister_subdev(sd);
+	kfree(to_motor_config(sd));
+
+	DBG_leaving;
+	return 0;
+}
+
+static const struct i2c_device_id ov5630_motor_id[] = {
+	{"ov5630_motor", 0},
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, ov5630_motor_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = "ov5630_motor",
+	.probe = ov5630_motor_probe,
+	.remove = ov5630_motor_remove,
+	/* .suspend = ov5630_suspend,
+	 * .resume = ov5630_resume, */
+	.id_table = ov5630_motor_id,
+};
+MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
+MODULE_DESCRIPTION("A low-level driver for OmniVision 5630 sensors");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/mrstci/mrstov5630_motor/ov5630_motor.h b/drivers/media/video/mrstci/mrstov5630_motor/ov5630_motor.h
new file mode 100644
index 0000000..302c218
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov5630_motor/ov5630_motor.h
@@ -0,0 +1,86 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <media/v4l2-subdev.h>
+
+/* VCM start current (mA) */
+#define MOTOR_INFIN_CUR		15
+/* VCM max current for Macro (mA) */
+#define MOTOR_MACRO_CUR		90
+/* DAC output max current (mA) */
+#define MOTOR_DAC_MAX_CUR	100
+/* DAC output min current (mA) */
+#define MOTOR_DAC_MIN_CUR	3
+
+#define MOTOR_DAC_BIT_RES	10
+#define MOTOR_DAC_MAX_CODE	((1 << MOTOR_DAC_BIT_RES) - 1)
+
+#define MOTOR_STEP_SHIFT	4
+
+#define MAX(x, y)	((x) > (y) ? (x) : (y))
+#define MIN(x, y)	((x) < (y) ? (x) : (y))
+
+/* DAC register related define */
+#define MOTOR_POWER_DOWN	(1 << 7)
+#define		PD_ENABLE	(1 << 7)
+#define		PD_DISABLE	(0)
+
+#define MOTOR_DAC_CODE_H(x)	((x >> 4) & 0x3f)
+#define MOTOR_DAC_CODE_L(x)	((x << 4) & 0xf0)
+
+#define MOTOR_DAC_CTRL_MODE_0	0x00
+#define MOTOR_DAC_CTRL_MODE_1(x)	(x & 0x07)
+#define MOTOR_DAC_CTRL_MODE_2(x)	((x & 0x07) | 0x08)
+
+#define SUB_MODE_1	0x01
+#define SUB_MODE_2	0x02
+#define SUB_MODE_3	0x03
+#define SUB_MODE_4	0x04
+#define SUB_MODE_5	0x05
+#define SUB_MODE_6	0x06
+#define SUB_MODE_7	0x07
+
+#define OV5630_MOTOR_ADDR	(0x18 >> 1)
+#define POWER_EN_PIN	7
+#define GPIO_AF_PD	95
+
+struct ov5630_motor{
+	unsigned int infin_cur;
+	unsigned int infin_code;
+	unsigned int macro_cur;
+	unsigned int macro_code;
+	unsigned int max_step;
+	unsigned int cur_code;
+	struct v4l2_subdev sd;
+};
+
+extern int ov5630_motor_init(struct i2c_client *client, struct ov5630_motor
+			     *config);
+extern int ov5630_motor_standby(void);
+extern int ov5630_motor_wakeup(void);
+extern int ov5630_motor_set_focus(struct i2c_client *c, int step,
+			   struct ov5630_motor *config);
+extern int ov5630_motor_get_focus(struct i2c_client *c, unsigned int *step,
+			   struct ov5630_motor *config);
+extern int ov5630_motor_max_step(struct i2c_client *c, unsigned int *max_code,
+			   struct ov5630_motor *config);
diff --git a/drivers/media/video/mrstci/mrstov9665/Kconfig b/drivers/media/video/mrstci/mrstov9665/Kconfig
new file mode 100644
index 0000000..ba9b692
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov9665/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_MRST_OV9665
+	tristate "Moorestown OV9665 SoC Sensor"
+	depends on I2C && VIDEO_MRST_ISP
+
+	---help---
+	  Say Y here if your platform support OV9665 SoC Sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mrstov9665.ko.
diff --git a/drivers/media/video/mrstci/mrstov9665/Makefile b/drivers/media/video/mrstci/mrstov9665/Makefile
new file mode 100644
index 0000000..871b6bf
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov9665/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_MRST_OV9665)	 += mrstov9665.o
+
+EXTRA_CFLAGS	+=	-I$(src)/../include
diff --git a/drivers/media/video/mrstci/mrstov9665/mrstov9665.c b/drivers/media/video/mrstci/mrstov9665/mrstov9665.c
new file mode 100644
index 0000000..04e553a
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov9665/mrstov9665.c
@@ -0,0 +1,972 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <linux/videodev2.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
+
+#include "ci_sensor_common.h"
+#include "ov9665.h"
+
+static int mrstov9665_debug;
+module_param(mrstov9665_debug, int, 0644);
+MODULE_PARM_DESC(mrstov9665_debug, "Debug level (0-1)");
+
+#define dprintk(level, fmt, arg...) do {			\
+	if (mrstov9665_debug >= level) 					\
+		printk(KERN_DEBUG "mrstisp@%s: " fmt "\n", \
+		       __func__, ## arg); } \
+	while (0)
+
+#define eprintk(fmt, arg...)	\
+	printk(KERN_ERR "mrstisp@%s: line %d: " fmt "\n",	\
+	       __func__, __LINE__, ## arg);
+
+#define DBG_entering	dprintk(2, "entering");
+#define DBG_leaving	dprintk(2, "leaving");
+#define DBG_line	dprintk(2, " line: %d", __LINE__);
+
+static inline struct ci_sensor_config *to_sensor_config(struct v4l2_subdev *sd)
+{
+	return container_of(sd, struct ci_sensor_config, sd);
+}
+
+static struct ov9665_format_struct {
+	__u8 *desc;
+	__u32 pixelformat;
+	struct regval_list *regs;
+} ov9665_formats[] = {
+	{
+		.desc		= "YUYV 4:2:2",
+		.pixelformat	= SENSOR_MODE_BT601,
+		.regs 		= NULL,
+	},
+};
+#define N_OV9665_FMTS ARRAY_SIZE(ov9665_formats)
+
+static struct ov9665_res_struct {
+	__u8 *desc;
+	int res;
+	int width;
+	int height;
+	/* FIXME: correct the fps values.. */
+	int fps;
+	bool used;
+	struct regval_list *regs;
+} ov9665_res[] = {
+	{
+		.desc		= "SXGA",
+		.res		= SENSOR_RES_SXGA,
+		.width		= 1280,
+		.height		= 1024,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov9665_res_sxga,
+	},
+	{
+		.desc		= "VGA",
+		.res		= SENSOR_RES_VGA,
+		.width		= 640,
+		.height		= 480,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= ov9665_res_vga,
+	},
+};
+#define N_RES (ARRAY_SIZE(ov9665_res))
+
+/*
+ * I2C Read & Write stuff
+ */
+static int ov9665_read(struct i2c_client *c, unsigned char reg,
+		       unsigned char *value)
+{
+	int ret;
+
+	ret = i2c_smbus_read_byte_data(c, reg);
+	if (ret >= 0) {
+		*value = (unsigned char) ret;
+		ret = 0;
+	}
+	return ret;
+}
+
+static int ov9665_write(struct i2c_client *c, unsigned char reg,
+			unsigned char value)
+{
+	int ret = i2c_smbus_write_byte_data(c, reg, value);
+	if (reg == 0x12 && (value & 0x80))
+		msleep(2);  /* Wait for reset to run */
+	return ret;
+}
+
+/*
+ * Write a list of register settings; ff/ff stops the process.
+ */
+static int ov9665_write_array(struct i2c_client *c, struct regval_list *vals)
+{
+	struct regval_list *p;
+	u8 read_val = 0;
+	int err_num = 0;
+	int i = 0;
+	p = vals;
+	while (p->reg_num != 0xff) {
+		ov9665_write(c, p->reg_num, p->value);
+		ov9665_read(c, p->reg_num, &read_val);
+		if (read_val != p->value)
+			err_num++;
+		p++;
+		i++;
+	}
+
+	return 0;
+}
+
+static int ov9665_set_data_pin_in(struct i2c_client *client)
+{
+	int ret = 0;
+
+	ret += ov9665_write(client, 0xd5, 0x00);
+	ret += ov9665_write(client, 0xd6, 0x00);
+
+	return ret;
+}
+
+static int ov9665_set_data_pin_out(struct i2c_client *client)
+{
+	int ret = 0;
+
+	ret += ov9665_write(client, 0xd5, 0xff);
+	ret += ov9665_write(client, 0xd6, 0xff);
+
+	return ret;
+}
+/*
+ * Sensor specific helper function
+ */
+static int ov9665_standby(void)
+{
+	/* Pull the pin to high to hardware standby */
+	gpio_set_value(GPIO_STDBY_PIN, 1);
+	dprintk(1, "PM: standby called\n");
+	return 0;
+}
+
+static int ov9665_wakeup(void)
+{
+	/* Pull the pin to low*/
+	gpio_set_value(GPIO_STDBY_PIN, 0);
+	dprintk(1, "PM: wakeup called\n");
+	msleep(10);
+	return 0;
+}
+
+static int ov9665_s_power(struct v4l2_subdev *sd, u32 val)
+{
+	if (val == 1)
+		ov9665_standby();
+	if (val == 0)
+		ov9665_wakeup();
+	return 0;
+}
+
+static int ov9665_init(struct i2c_client *c)
+{
+	int ret;
+	struct v4l2_subdev *sd = i2c_get_clientdata(c);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	u8 reg = 0;
+
+	/* Fill the configuration structure */
+	/* Note this default configuration value */
+	info->mode = ov9665_formats[0].pixelformat;
+	info->res = ov9665_res[0].res;
+	info->type = SENSOR_TYPE_SOC;
+	info->bls = SENSOR_BLS_OFF;
+	info->gamma = SENSOR_GAMMA_ON;
+	info->cconv = SENSOR_CCONV_ON;
+	info->blc = SENSOR_BLC_AUTO;
+	info->agc = SENSOR_AGC_AUTO;
+	info->awb = SENSOR_AWB_AUTO;
+	info->aec = SENSOR_AEC_AUTO;
+	info->bus_width = SENSOR_BUSWIDTH_8BIT_ZZ;
+	info->ycseq = SENSOR_YCSEQ_YCBYCR;
+	info->conv422 = SENSOR_CONV422_COSITED;
+	info->bpat = SENSOR_BPAT_GRGRBGBG;
+	info->field_inv = SENSOR_FIELDINV_NOSWAP;
+	info->field_sel = SENSOR_FIELDSEL_BOTH;
+	info->hpol = SENSOR_HPOL_REFPOS;
+	info->vpol = SENSOR_VPOL_POS;
+	info->edge = SENSOR_EDGE_FALLING;
+	info->flicker_freq = SENSOR_FLICKER_100;
+	info->cie_profile = 0;
+	memcpy(info->name, "ov9665", 7);
+
+	ret = ov9665_write(c, 0x12, 0x80);
+	/* Set registers into default config value */
+	ret += ov9665_write_array(c, ov9665_def_reg);
+
+	ov9665_read(c, 0x09, &reg);
+	reg = reg | 0x10;
+	ov9665_write(c, 0x09, reg);
+	ov9665_set_data_pin_in(c);
+	ssleep(1);
+
+	return ret;
+}
+
+static int distance(struct ov9665_res_struct *res, u32 w, u32 h)
+{
+	int ret;
+	if (res->width < w || res->height < h)
+		return -1;
+
+	ret = ((res->width - w) + (res->height - h));
+	return ret;
+}
+static int ov9665_try_res(u32 *w, u32 *h)
+{
+	struct ov9665_res_struct *res_index, *p = NULL;
+	int dis, last_dis = ov9665_res->width + ov9665_res->height;
+
+	dprintk(1, "&&&&&  before %dx%d", *w, *h);
+	for (res_index = ov9665_res;
+	     res_index < ov9665_res + N_RES;
+	     res_index++) {
+		if ((res_index->width <= *w) && (res_index->height <= *h))
+			break;
+		dis = distance(res_index, *w, *h);
+		if (dis < last_dis) {
+			last_dis = dis;
+			p = res_index;
+		}
+	}
+	if ((res_index->width < *w) || (res_index->height < *h)) {
+		if (res_index != ov9665_res)
+			res_index--;
+	}
+
+	/*
+	if (p == NULL) {
+		p = ov2650_res;
+	}
+
+	if ((w != NULL) && (h != NULL)) {
+		*w = p->width;
+		*h = p->height;
+	}
+	*/
+	if (res_index == ov9665_res + N_RES)
+		res_index = ov9665_res + N_RES - 1;
+
+	*w = res_index->width;
+	*h = res_index->height;
+
+	dprintk(1, "&&&&&  after %dx%d", *w, *h);
+	return 0;
+}
+
+static struct ov9665_res_struct *ov9665_to_res(u32 w, u32 h)
+{
+	struct ov9665_res_struct *res_index;
+
+	for (res_index = ov9665_res;
+	     res_index < ov9665_res + N_RES;
+	     res_index++)
+		if ((res_index->width == w) && (res_index->height == h))
+			break;
+
+	if (res_index >= ov9665_res + N_RES)
+		res_index--;   /* Take the bigger one */
+
+	return res_index;
+}
+
+static int ov9665_try_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	DBG_entering;
+	return ov9665_try_res(&fmt->fmt.pix.width, &fmt->fmt.pix.height);
+	DBG_leaving;
+}
+
+static int ov9665_get_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	unsigned short width, height;
+	int index;
+
+	ci_sensor_res2size(info->res, &width, &height);
+
+	/* Marked the current sensor res as being "used" */
+	for (index = 0; index < N_RES; index++) {
+		if ((width == ov9665_res[index].width) &&
+		    (height == ov9665_res[index].height)) {
+			ov9665_res[index].used = 1;
+			continue;
+		}
+		ov9665_res[index].used = 0;
+	}
+
+	fmt->fmt.pix.width = width;
+	fmt->fmt.pix.height = height;
+	return 0;
+}
+
+static int ov9665_set_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+{
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	int ret = 0;
+	struct ov9665_res_struct *res_index;
+	u32 width, height;
+	int index;
+
+	DBG_entering;
+
+	width = fmt->fmt.pix.width;
+	height = fmt->fmt.pix.height;
+
+	ret = ov9665_try_res(&width, &height);
+	res_index = ov9665_to_res(width, height);
+
+	ov9665_wakeup();
+	/* if ((info->res != res_index->res) && (res_index->regs)) { */
+	if ( res_index->regs) {
+		ret = ov9665_write(c, 0x12, 0x80);
+		ret += ov9665_write_array(c, ov9665_def_reg);
+		ret += ov9665_write_array(c, res_index->regs);
+		/* Add delay here to get better image */
+
+		for (index = 0; index < N_RES; index++) {
+			if ((width == ov9665_res[index].width) &&
+			    (height == ov9665_res[index].height)) {
+				ov9665_res[index].used = 1;
+				continue;
+			}
+			ov9665_res[index].used = 0;
+		}
+
+		for (index = 0; index < N_RES; index++)
+			dprintk(2, "index = %d, used = %d\n", index,
+				ov9665_res[index].used);
+
+	}
+	info->res = res_index->res;
+
+	DBG_leaving;
+	return ret;
+}
+
+static int ov9665_q_hflip(struct v4l2_subdev *sd, __s32 *value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	int ret;
+	unsigned char v = 0;
+
+	ret = ov9665_read(client, 0x04, &v);
+	*value = ((v & 0x80) == 0x80);
+	return ret;
+}
+
+static int ov9665_t_hflip(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	unsigned char v = 0;
+	int ret;
+
+	value = value >= 1 ? 1 : 0;
+	ret = ov9665_read(client, 0x33, &v);
+	if (value)
+		v |= 0x08;
+	else
+		v &= ~0x08;
+	ret += ov9665_write(client, 0x33, v);
+
+	ret += ov9665_read(client, 0x04, &v);
+	if (value)
+		v |= 0x80;
+	else
+		v &= ~0x80;
+	ret += ov9665_write(client, 0x04, v);
+	msleep(10);  /* FIXME */
+	return ret;
+}
+
+static int ov9665_q_vflip(struct v4l2_subdev *sd, __s32 *value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	int ret;
+	unsigned char v = 0;
+
+	ret = ov9665_read(client, 0x04, &v);
+	*value = ((v & 0x40) == 0x40);
+	return ret;
+}
+
+static int ov9665_t_vflip(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	unsigned char v = 0;
+	int ret;
+
+	value = value >= 1 ? 1 : 0;
+	ret = ov9665_read(client, 0x04, &v);
+	if (value)
+		v |= 0x40;
+	else
+		v &= ~0x40;
+	ret += ov9665_write(client, 0x04, v);
+	msleep(10);  /* FIXME */
+	return ret;
+}
+
+static struct ov9665_control {
+	struct v4l2_queryctrl qc;
+	int (*query)(struct v4l2_subdev *sd, __s32 *value);
+	int (*tweak)(struct v4l2_subdev *sd, int value);
+} ov9665_controls[] = {
+	{
+		.qc = {
+			.id = V4L2_CID_VFLIP,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "Vertical flip",
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 0,
+		},
+		.tweak = ov9665_t_vflip,
+		.query = ov9665_q_vflip,
+	},
+	{
+		.qc = {
+			.id = V4L2_CID_HFLIP,
+			.type = V4L2_CTRL_TYPE_BOOLEAN,
+			.name = "Horizontal mirror",
+			.minimum = 0,
+			.maximum = 1,
+			.step = 1,
+			.default_value = 0,
+		},
+		.tweak = ov9665_t_hflip,
+		.query = ov9665_q_hflip,
+	},
+};
+#define N_CONTROLS (ARRAY_SIZE(ov9665_controls))
+
+static struct ov9665_control *ov9665_find_control(__u32 id)
+{
+	int i;
+
+	for (i = 0; i < N_CONTROLS; i++)
+		if (ov9665_controls[i].qc.id == id)
+			return ov9665_controls + i;
+	return NULL;
+}
+
+static int ov9665_queryctrl(struct v4l2_subdev *sd,
+			    struct v4l2_queryctrl *qc)
+{
+	struct ov9665_control *ctrl = ov9665_find_control(qc->id);
+
+	if (ctrl == NULL)
+		return -EINVAL;
+	*qc = ctrl->qc;
+	return 0;
+}
+
+static int ov9665_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+	struct ov9665_control *octrl = ov9665_find_control(ctrl->id);
+	int ret;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret = octrl->query(sd, &ctrl->value);
+	if (ret >= 0)
+		return 0;
+	return ret;
+}
+
+static int ov9665_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+	struct ov9665_control *octrl = ov9665_find_control(ctrl->id);
+	int ret;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret =  octrl->tweak(sd, ctrl->value);
+	if (ret >= 0)
+		return 0;
+	return ret;
+}
+
+#if 0
+static int ov9665_get_caps(struct i2c_client *c, struct ci_sensor_caps *caps)
+{
+	if (caps == NULL)
+		return -EIO;
+
+	caps->bus_width = SENSOR_BUSWIDTH_8BIT_ZZ;
+	caps->mode	= SENSOR_MODE_BT601;
+	caps->field_inv = SENSOR_FIELDINV_NOSWAP;
+	caps->field_sel = SENSOR_FIELDSEL_BOTH;
+	caps->ycseq	= SENSOR_YCSEQ_YCBYCR;
+	caps->conv422	= SENSOR_CONV422_COSITED;
+	caps->bpat	= SENSOR_BPAT_GRGRBGBG;
+	caps->hpol	= SENSOR_HPOL_REFPOS;
+	caps->vpol	= SENSOR_VPOL_POS;
+	caps->edge	= SENSOR_EDGE_FALLING;
+	caps->bls	= SENSOR_BLS_OFF;
+	caps->gamma	= SENSOR_GAMMA_ON;
+	caps->cconv	= SENSOR_CCONV_ON;
+	caps->res	= SENSOR_RES_SXGA | SENSOR_RES_VGA;
+	caps->blc	= SENSOR_BLC_AUTO;
+	caps->agc	= SENSOR_AGC_AUTO;
+	caps->awb	= SENSOR_AWB_AUTO;
+	caps->aec	= SENSOR_AEC_AUTO;
+	caps->cie_profile	= 0;
+	caps->flicker_freq	= SENSOR_FLICKER_100 | SENSOR_FLICKER_120;
+	caps->type	= SENSOR_TYPE_SOC;
+	/* caps->name	= "ov9665"; */
+	strcpy(caps->name, "ov9665");
+
+	return 0;
+}
+
+static int ov9665_get_config(struct i2c_client *c,
+			     struct ci_sensor_config *config)
+{
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+
+	if (config == NULL) {
+		printk(KERN_WARNING "sensor_get_config: NULL pointer\n");
+		return -EIO;
+	}
+
+	memset(config, 0, sizeof(struct ci_sensor_config *));
+	memcpy(config, info, sizeof(struct ci_sensor_config));
+
+	return 0;
+}
+
+static int ov9665_setup(struct i2c_client *c,
+			const struct ci_sensor_config *config)
+{
+	int ret;
+	struct ov9665_res_struct *res_index;
+	struct ci_sensor_config *info = i2c_get_clientdata(c);
+	u16 width, high;
+
+	/* Soft reset camera first*/
+	ret = ov9665_write(c, 0x12, 0x80);
+
+	/* Set registers into default config value */
+	ret += ov9665_write_array(c, ov9665_def_reg);
+
+	/* set image resolution */
+	ci_sensor_res2size(config->res, &width, &high);
+	ret += ov9665_try_res(c, &width, &high);
+	res_index = ov9665_find_res(width, high);
+	if (res_index->regs)
+		ret += ov9665_write_array(c, res_index->regs);
+	if (!ret)
+		info->res = res_index->res;
+
+	/* Add some delay here to get a better image*/
+	ssleep(1);
+
+	return ret;
+}
+
+static int ov9665_set_data_pin_in(struct i2c_client *client)
+{
+	int ret = 0;
+
+	ret += ov9665_write(client, 0xd5, 0x00);
+	ret += ov9665_write(client, 0xd6, 0x00);
+
+	return ret;
+}
+
+static int ov9665_set_data_pin_out(struct i2c_client *client)
+{
+	int ret = 0;
+
+	ret += ov9665_write(client, 0xd5, 0xff);
+	ret += ov9665_write(client, 0xd6, 0xff);
+
+	return ret;
+}
+/*
+ * File operation functions
+ */
+static int ov9665_open(struct i2c_setting *c, void *priv)
+{
+	struct i2c_client *client = c->sensor_client;
+	int ret = 0;
+	u8 reg = 0;
+	/* Just wake up sensor */
+	if (ov9665_wakeup())
+		return -EIO;
+
+	ov9665_init(client);
+	ret = ov9665_read(client, 0x09, &reg);
+	reg = reg | 0x10;
+	ret += ov9665_write(client, 0x09, reg);
+
+	if (ov9665_set_data_pin_in(client))
+		return EIO;
+/*
+	if (ov9665_standby())
+		return EIO;
+*/
+	return ret;
+}
+
+static int ov9665_release(struct i2c_setting *c, void *priv)
+{
+	/* Just suspend the sensor */
+	if (ov9665_standby())
+		return EIO;
+	return 0;
+}
+
+static int ov9665_on(struct i2c_setting *c)
+{
+	struct i2c_client *client = c->sensor_client;
+	int ret = 0;
+	u8 reg = 0;
+
+	ret = ov9665_read(client, 0x09, &reg);
+	reg = reg & ~0x10;
+	ret = ov9665_write(client, 0x09, reg);
+
+	if (ov9665_set_data_pin_out(client))
+		return EIO;
+
+	return ret;
+}
+
+static int ov9665_off(struct i2c_setting *c)
+{
+	struct i2c_client *client = c->sensor_client;
+	int ret = 0;
+	u8 reg = 0;
+/*
+	ret = ov9665_read(client, 0x09, &reg);
+	reg = reg | 0x10;
+	ret += ov9665_write(client, 0x09, reg);
+*/
+	if (ov9665_set_data_pin_in(client))
+		return EIO;
+
+	return ret;
+}
+
+static struct sensor_device ov9665 = {
+	.name	= "OV9665",
+	.type	= SENSOR_TYPE_SOC,
+	.minor	= -1,
+	.open	= ov9665_open,
+	.release = ov9665_release,
+	.on = ov9665_on,
+	.off = ov9665_off,
+	.querycap = ov9665_get_caps,
+	.get_config = ov9665_get_config,
+	.set_config = ov9665_setup,
+	.enum_parm = ov9665_queryctrl,
+	.get_parm = ov9665_g_ctrl,
+	.set_parm = ov9665_s_ctrl,
+	.try_res = ov9665_try_res,
+	.set_res = ov9665_set_res,
+	.suspend = ov9665_standby,
+	.resume = ov9665_wakeup,
+	.get_ls_corr_config = NULL,
+	.set_awb = NULL,
+	.set_aec = NULL,
+	.set_blc = NULL,
+	/* TBC */
+};
+#endif
+
+static int ov9665_s_stream(struct v4l2_subdev *sd, int enable)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	u8 reg = 0;
+
+	DBG_entering;
+	if (enable) {
+		ov9665_read(client, 0x09, &reg);
+		reg = reg & ~0x10;
+		ov9665_write(client, 0x09, reg);
+		ov9665_set_data_pin_out(client);
+		ssleep(1);
+
+	} else {
+		ov9665_read(client, 0x09, &reg);
+		reg = reg | 0x10;
+		ov9665_write(client, 0x09, reg);
+		ov9665_set_data_pin_in(client);
+	}
+
+	DBG_leaving;
+	return 0;
+}
+
+static int ov9665_enum_framesizes(struct v4l2_subdev *sd,
+				  struct v4l2_frmsizeenum *fsize)
+{
+	unsigned int index = fsize->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+	fsize->discrete.width = ov9665_res[index].width;
+	fsize->discrete.height = ov9665_res[index].height;
+	fsize->reserved[0] = ov9665_res[index].used;
+
+	DBG_leaving;
+
+	return 0;
+}
+
+static int ov9665_enum_frameintervals(struct v4l2_subdev *sd,
+				      struct v4l2_frmivalenum *fival)
+{
+	unsigned int index = fival->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+	fival->discrete.numerator = 1;
+	fival->discrete.denominator = ov9665_res[index].fps;
+
+	DBG_leaving;
+
+	return 0;
+}
+
+static int ov9665_g_chip_ident(struct v4l2_subdev *sd,
+		struct v4l2_dbg_chip_ident *chip)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+#define V4L2_IDENT_OV9665 8246
+	return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV9665, 0);
+}
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int ov9665_g_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	unsigned char val = 0;
+	int ret;
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	ret = ov9665_read(client, reg->reg & 0xffff, &val);
+	reg->val = val;
+	reg->size = 1;
+	return ret;
+}
+
+static int ov9665_s_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	ov9665_write(client, reg->reg & 0xffff, reg->val & 0xff);
+	return 0;
+}
+#endif
+
+static const struct v4l2_subdev_video_ops ov9665_video_ops = {
+	.try_fmt = ov9665_try_fmt,
+	.s_fmt = ov9665_set_fmt,
+	.g_fmt = ov9665_get_fmt,
+	.s_stream = ov9665_s_stream,
+	.enum_framesizes = ov9665_enum_framesizes,
+	.enum_frameintervals = ov9665_enum_frameintervals,
+};
+
+static const struct v4l2_subdev_core_ops ov9665_core_ops = {
+	.g_chip_ident = ov9665_g_chip_ident,
+	.queryctrl = ov9665_queryctrl,
+	.g_ctrl = ov9665_g_ctrl,
+	.s_ctrl = ov9665_s_ctrl,
+	.s_gpio = ov9665_s_power,
+	/*.g_ext_ctrls = ov9665_g_ext_ctrls,*/
+	/*.s_ext_ctrls = ov9665_s_ext_ctrls,*/
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+	.g_register = ov9665_g_register,
+	.s_register = ov9665_s_register,
+#endif
+};
+
+static const struct v4l2_subdev_ops ov9665_ops = {
+	.core = &ov9665_core_ops,
+	.video = &ov9665_video_ops,
+};
+/*
+ * Basic i2c stuff
+ */
+/*
+static unsigned short normal_i2c[] = {0x30, I2C_CLIENT_END};
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver ov9665_driver;
+*/
+static int ov9665_detect(struct i2c_client *client)
+{
+	struct i2c_adapter *adapter = client->adapter;
+	int adap_id = i2c_adapter_id(adapter);
+	u8 config = 0;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		return -ENODEV;
+
+	if (adap_id != 1)
+		return -ENODEV;
+
+	ov9665_wakeup();
+
+	ov9665_read(client, 0x0a, &config);
+	if (config != 0x96)
+		return -ENODEV;
+
+	ov9665_read(client, 0x0b, &config);
+	if (config != 0x63)
+		return -ENODEV;
+
+	return 0;
+}
+
+static int ov9665_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	struct ci_sensor_config *info;
+	struct v4l2_subdev *sd;
+	int ret = -1;
+
+	DBG_entering;
+	/*
+	 * Setup sensor configuration structure
+	 */
+	info = kzalloc(sizeof(struct ci_sensor_config), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	ret = ov9665_detect(client);
+	if (ret) {
+		kfree(info);
+		return -ENODEV;
+	}
+
+	sd = &info->sd;
+	v4l2_i2c_subdev_init(sd, client, &ov9665_ops);
+
+	/*
+	 * Initialization OV9665
+	 * then turn into standby mode
+	 */
+	/* ret = ov9665_standby(); */
+	ret = ov9665_init(client);
+	if (ret) {
+		eprintk("error init ov9665");
+		goto err_1;
+	}
+
+	ov9665_standby();
+	printk(KERN_INFO "Init ov9665 sensor success\n");
+	DBG_leaving;
+	return 0;
+
+err_1:
+	kfree(info);
+	return ret;
+}
+
+/*
+ * XXX: Need to be checked
+ */
+static int ov9665_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+	v4l2_device_unregister_subdev(sd);
+	kfree(to_sensor_config(sd));
+
+	return 0;
+}
+
+static const struct i2c_device_id ov9665_id[] = {
+	{"ov9665", 0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, ov9665_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = "ov9665",
+	.probe = ov9665_probe,
+	.remove = ov9665_remove,
+	.id_table = ov9665_id,
+};
+
+MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
+MODULE_DESCRIPTION("A low-level driver for OmniVision 9665 sensors");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/mrstci/mrstov9665/ov9665.h b/drivers/media/video/mrstci/mrstov9665/ov9665.h
new file mode 100644
index 0000000..6fc9d12
--- /dev/null
+++ b/drivers/media/video/mrstci/mrstov9665/ov9665.h
@@ -0,0 +1,263 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#define I2C_OV9665	0x60
+/* Should add to kernel source */
+#define I2C_DRIVERID_OV9665	1047
+/* GPIO pin on Moorestown */
+#define GPIO_SCLK_25	44
+#define GPIO_STB_PIN	47
+#define GPIO_STDBY_PIN	48
+#define GPIO_RESET_PIN	50
+
+struct regval_list {
+	u8 reg_num;
+	u8 value;
+};
+
+/*
+ * Default register value
+ * 1280x1024 YUV
+ */
+static struct regval_list ov9665_def_reg[] = {
+	{0x3E, 0x80},
+	{0x12, 0x80},
+
+	{0xd5, 0xff},
+	{0xd6, 0x3f},
+
+	{0x3d, 0x3c},
+	{0x11, 0x81},
+	{0x2a, 0x00},
+	{0x2b, 0x00},
+
+	{0x3a, 0xf1},
+	{0x3b, 0x00},
+	{0x3c, 0x58},
+	{0x3e, 0x50},
+	{0x71, 0x00},
+
+	{0x15, 0x00},
+	{0x6a, 0x24},
+	{0x85, 0xe7},
+
+	{0x63, 0x01},
+
+	{0x17, 0x0c},
+	{0x18, 0x5c},
+	{0x19, 0x01},
+	{0x1a, 0x82},
+	{0x03, 0x03},
+	{0x2b, 0x00},
+
+	{0x36, 0xb4},
+	{0x65, 0x10},
+	{0x70, 0x02},
+	{0x71, 0x9f},
+	{0x64, 0x24},
+
+	{0x43, 0x00},
+	{0x5D, 0x55},
+	{0x5E, 0x57},
+	{0x5F, 0x21},
+
+	{0x24, 0x3e},
+	{0x25, 0x38},
+	{0x26, 0x72},
+
+	{0x14, 0x68},
+	{0x0C, 0x3a}, /* Auto detect for 50/60 */
+	{0x4F, 0x9E},
+	{0x50, 0x84},
+	{0x5A, 0x67},
+
+	{0x7d, 0x30},
+	{0x7e, 0x00},
+	{0x82, 0x03},
+	{0x7f, 0x00},
+	{0x83, 0x07},
+	{0x80, 0x03},
+	{0x81, 0x04},
+
+	{0x96, 0xf0},
+	{0x97, 0x00},
+	{0x92, 0x33},
+	{0x94, 0x5a},
+	{0x93, 0x3a},
+	{0x95, 0x48},
+	{0x91, 0xfc},
+	{0x90, 0xff},
+	{0x8e, 0x4e},
+	{0x8f, 0x4e},
+	{0x8d, 0x13},
+	{0x8c, 0x0c},
+	{0x8b, 0x0c},
+	{0x86, 0x9e},
+	{0x87, 0x11},
+	{0x88, 0x22},
+	{0x89, 0x05},
+	{0x8a, 0x03},
+
+	{0x9b, 0x0e},
+	{0x9c, 0x1c},
+	{0x9d, 0x34},
+	{0x9e, 0x5a},
+	{0x9f, 0x68},
+	{0xa0, 0x76},
+	{0xa1, 0x82},
+	{0xa2, 0x8e},
+	{0xa3, 0x98},
+	{0xa4, 0xa0},
+	{0xa5, 0xb0},
+	{0xa6, 0xbe},
+	{0xa7, 0xd2},
+	{0xa8, 0xe2},
+	{0xa9, 0xee},
+	{0xaa, 0x18},
+
+	{0xAB, 0xe7},
+	{0xb0, 0x43},
+	{0xac, 0x04},
+	{0x84, 0x40},
+
+	{0xad, 0x84},
+	{0xd9, 0x24},
+	{0xda, 0x00},
+	{0xae, 0x10},
+
+	{0xab, 0xe7},
+	{0xb9, 0xa0},
+	{0xba, 0x80},
+	{0xbb, 0xa0},
+	{0xbc, 0x80},
+
+	{0xbd, 0x08},
+	{0xbe, 0x19},
+	{0xbf, 0x02},
+	{0xc0, 0x08},
+	{0xc1, 0x2a},
+	{0xc2, 0x34},
+	{0xc3, 0x2d},
+	{0xc4, 0x2d},
+	{0xc5, 0x00},
+	{0xc6, 0x98},
+	{0xc7, 0x18},
+	{0x69, 0x48},
+
+	{0x74, 0xc0},
+
+	{0x7c, 0x18},
+	{0x65, 0x11},
+	{0x66, 0x00},
+	{0x41, 0xa0},
+	{0x5b, 0x28},
+	{0x60, 0x84},
+	{0x05, 0x07},
+	{0x03, 0x03},
+	{0xd2, 0x8c},
+
+	{0xc7, 0x90},
+	{0xc8, 0x06},
+	{0xcb, 0x40},
+	{0xcc, 0x40},
+	{0xcf, 0x00},
+	{0xd0, 0x20},
+	{0xd1, 0x00},
+	{0xc7, 0x18},
+
+	{0x0d, 0x82},
+	{0x0d, 0x80},
+
+	{0x09, 0x01},
+
+	{0xff, 0xff},
+};
+
+/* 1280x1024 */
+static struct regval_list ov9665_res_sxga[] = {
+	{0x0c, 0xbc}, /* note this */
+	{0xff, 0xff},
+};
+
+/* 640x480 */
+static struct regval_list ov9665_res_vga[] = {
+	/* Fclk/4 */
+	{0x11, 0x80},
+	{0x63, 0x00},
+
+	{0x12, 0x40}, /*VGA format*/
+	{0x14, 0x30}, /*4x*/
+	{0x0c, 0xbc},
+	{0x4d, 0x09},
+	{0x5c, 0x80}, /* Full average AEC */
+
+	/* Windows setting */
+	{0x17, 0x0c},
+	{0x18, 0x5c},
+	{0x19, 0x02},
+	{0x1a, 0x3f},
+	{0x03, 0x03},
+	{0x32, 0xad},
+
+	/* 50/60Hz AEC */
+	{0x5a, 0x23},
+	{0x2b, 0x00},
+
+	{0x64, 0xa4},
+	/*
+	{0x4F, 0x4f},
+	{0x50, 0x42},
+	*/
+	{0x4F, 0x9e},
+	{0x50, 0x84},
+	{0x97, 0x0a},
+	{0xad, 0x82},
+	{0xd9, 0x11},
+
+	/* Scale window */
+	{0xb9, 0x50},
+	{0xba, 0x3c},
+	{0xbb, 0x50},
+	{0xbc, 0x3c},
+
+	{0xad, 0x80},
+	{0xd9, 0x00},
+	{0xac, 0x0f},
+	{0x84, 0x86},
+
+	/*This is for Color Matrix*/
+	{0xbd, 0x05},
+	{0xbe, 0x16},
+	{0xbf, 0x05},
+	{0xc0, 0x07},
+	{0xc1, 0x18},
+	{0xc2, 0x1f},
+	{0xc3, 0x2b},
+	{0xc4, 0x2b},
+	{0xc5, 0x00},
+
+	{0x0d, 0x92},
+	{0x0d, 0x90},
+
+	{0xff, 0xff},
+};
diff --git a/drivers/media/video/mrstci/mrsts5k4e1/Kconfig b/drivers/media/video/mrstci/mrsts5k4e1/Kconfig
new file mode 100755
index 0000000..7dee787
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_MRST_S5K4E1
+	tristate "Moorestown s5k4e1 RAW Sensor"
+	depends on I2C && VIDEO_MRST_ISP
+
+	---help---
+	  Say Y here if your platform support s5k4e1 RAW Sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mrstov2650.ko.
diff --git a/drivers/media/video/mrstci/mrsts5k4e1/Makefile b/drivers/media/video/mrstci/mrsts5k4e1/Makefile
new file mode 100644
index 0000000..8733fa8
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_MRST_S5K4E1)	 += mrsts5k4e1.o
+
+EXTRA_CFLAGS	+=	-I$(src)/../include
diff --git a/drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.c b/drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.c
new file mode 100755
index 0000000..f644531
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.c
@@ -0,0 +1,1024 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
+
+#include "ci_sensor_common.h"
+#include "mrsts5k4e1.h"
+/* #include "priv.h" */
+/* extern const struct DumpRegs regs_d[]; */
+
+static int s5k4e1_debug;
+module_param(s5k4e1_debug, int, 0644);
+MODULE_PARM_DESC(s5k4e1_debug, "Debug level (0-1)");
+
+#define dprintk(level, fmt, arg...) \
+	do { \
+		if (s5k4e1_debug >= level) \
+			printk(KERN_DEBUG "mrstisp@%s: " fmt "\n", \
+			       __func__, ## arg);\
+	} while (0)
+
+#define eprintk(fmt, arg...)	\
+	printk(KERN_ERR "mrstisp@%s:" fmt "\n",	\
+	       __func__, ## arg);
+
+#define DBG_entering	dprintk(1, "entering");
+#define DBG_leaving	dprintk(1, "leaving");
+#define DBG_line	dprintk(1, " line: %d", __LINE__);
+
+static inline struct ci_sensor_config *to_sensor_config(struct v4l2_subdev *sd)
+{
+	return container_of(sd, struct ci_sensor_config, sd);
+}
+
+static struct s5k4e1_format_struct {
+	__u8 *desc;
+	__u32 pixelformat;
+	struct regval_list *regs;
+} s5k4e1_formats[] = {
+	{
+		.desc		= "Raw RGB Bayer",
+		.pixelformat	= SENSOR_MODE_MIPI,
+		.regs 		= NULL,
+	},
+};
+#define N_S5K4E1_FMTS ARRAY_SIZE(s5k4e1_formats)
+
+static struct s5k4e1_res_struct {
+	__u8 *desc;
+	int res;
+	int width;
+	int height;
+	/* FIXME: correct the fps values.. */
+	int fps;
+	bool used;
+	struct regval_list *regs;
+} s5k4e1_res[] = {
+	{
+		.desc		= "QSXGA_PLUS4",
+		.res		= SENSOR_RES_QXGA_PLUS,
+		.width		= 2592,
+		.height		= 1944,
+		.fps		= 15,
+		.used		= 0,
+		.regs		= s5k4e1_res_qsxga_plus4,
+	},
+	{
+		.desc		= "1080P",
+		.res		= SENSOR_RES_1080P,
+		.width		= 1920,
+		.height		= 1080,
+		.fps		= 25,
+		.used		= 0,
+		.regs		= s5k4e1_res_1080p,
+	},
+	{
+		.desc 		= "VGA_PLUS",
+		.res		= SENSOR_RES_VGA_PLUS,
+		.width		= 1304,
+		.height		= 980,
+		.fps		= 30,
+		.used		= 0,
+		.regs		= s5k4e1_res_vga_ac04_bill,
+	},
+	{
+		.desc		= "720p",
+		.res		= SENSOR_RES_720P,
+		.width		= 1280,
+		.height		= 720,
+		.fps		= 30,
+		.used		= 0,
+		.regs		= s5k4e1_res_720p,
+	},
+	{
+		.desc 		= "VGA",
+		.res		= SENSOR_RES_VGA,
+		.width		= 640,
+		.height		= 480,
+		.used		= 0,
+		.fps		= 40,
+		.regs		= s5k4e1_res_vga_ac04_bill,
+	},
+};
+
+#define N_RES (ARRAY_SIZE(s5k4e1_res))
+
+/*
+ * I2C Read & Write stuff
+ */
+static int s5k4e1_read(struct i2c_client *c, u32 reg, u32 *value)
+{
+	int ret;
+	int i;
+	struct i2c_msg msg[2];
+	u8 msgbuf[2];
+	u8 ret_val = 0;
+	*value = 0;
+	/* Read needs two message to go */
+	memset(&msg, 0, sizeof(msg));
+	msgbuf[0] = 0;
+	msgbuf[1] = 0;
+	i = 0;
+
+	msgbuf[i++] = ((u16)reg) >> 8;
+	msgbuf[i++] = ((u16)reg) & 0xff;
+	msg[0].addr = c->addr;
+	msg[0].buf = msgbuf;
+	msg[0].len = i;
+
+	msg[1].addr = c->addr;
+	msg[1].flags = I2C_M_RD;
+	msg[1].buf = &ret_val;
+	msg[1].len = 1;
+
+	ret = i2c_transfer(c->adapter, &msg[0], 2);
+	*value = ret_val;
+
+	ret = (ret == 2) ? 0 : -1;
+	dprintk(2, "reg:0x%8x, value:0x%8x - %s", reg, *value,
+		(ret ? "failed" : "succesfully"));
+	return ret;
+}
+
+static int s5k4e1_write(struct i2c_client *c, u32 reg, u32 value)
+{
+	int ret, i;
+	struct i2c_msg msg;
+	u8 msgbuf[3];
+
+	/* Writing only needs one message */
+	memset(&msg, 0, sizeof(msg));
+	i = 0;
+	msgbuf[i++] = ((u16)reg) >> 8;
+	msgbuf[i++] = (u16)reg & 0xff;
+	msgbuf[i++] = (u8)value;
+
+	msg.addr = c->addr;
+	msg.flags = 0;
+	msg.buf = msgbuf;
+	msg.len = i;
+
+	ret = i2c_transfer(c->adapter, &msg, 1);
+
+	/* If this is a reset register, wait for 1ms */
+	if (reg == 0x0103 && (value & 0x01))
+		/*Note here, check if this is needed */
+		msleep(4);
+
+	ret = (ret == 1) ? 0 : -1;
+	dprintk(2, "reg:0x%8x, value:0x%8x - %s", reg, value,
+		(ret ? "failed" : "successfully"));
+	return ret;
+}
+
+static int s5k4e1_write_array(struct i2c_client *c, struct regval_list *vals)
+{
+	struct regval_list *p;
+	u32 read_val = 0;
+	int err_num = 0;
+	int i = 0;
+
+	DBG_entering;
+
+	p = vals;
+	while (p->reg_num != 0xffff) {
+		s5k4e1_write(c, (u32)p->reg_num, (u32)p->value);
+		s5k4e1_read(c, (u32)p->reg_num, &read_val);
+		/* msleep(100);*/
+		if (read_val != p->value) {
+			eprintk("0x%x write error:should be 0x%x, but 0x%x",
+				p->reg_num, p->value, read_val);
+			err_num++;
+		}
+		p++;
+		i++;
+	}
+	dprintk(1, "sucessfully wrote %d registers, err is %d", i,
+	       err_num);
+	return 0;
+}
+
+/*
+ * Sensor specific helper function
+ */
+static int s5k4e1_standby(void)
+{
+	gpio_set_value(GPIO_STDBY_PIN, 1);
+	dprintk(1, "PM: standby called\n");
+	return 0;
+}
+
+static int s5k4e1_wakeup(void)
+{
+	gpio_set_value(GPIO_STDBY_PIN, 0);
+	dprintk(1, "PM: wakeup called\n");
+	return 0;
+}
+
+static int s5k4e1_s_power(struct v4l2_subdev *sd, u32 val)
+{
+	if (val == 1)
+		s5k4e1_standby();
+	if (val == 0)
+		s5k4e1_wakeup();
+	return 0;
+}
+
+static int s5k4e1_set_img_ctrl(struct i2c_client *c,
+			       const struct ci_sensor_config *config)
+{
+	int err = 0;
+
+	DBG_entering;
+
+	switch (config->blc) {
+		/* only SENSOR_BLC_AUTO supported */
+	case SENSOR_BLC_AUTO:
+		break;
+	default:
+		dprintk(1, "BLC not supported,\
+			set to BLC_AUTO by default.");
+	}
+
+	switch (config->bls) {
+		/* only SENSOR_BLS_OFF supported */
+	case SENSOR_BLS_OFF:
+		break;
+	default:
+		dprintk(1, "Black level not supported,\
+			set to BLS_OFF by default.");
+	}
+
+	switch (config->agc) {
+		/* only SENSOR_AGC_OFF supported */
+	case SENSOR_AGC_OFF:
+		break;
+	default:
+		dprintk(1, "AGC not supported,\
+			set to AGC_OFF by default.");
+	}
+
+	switch (config->awb) {
+		/* only SENSOR_AWB_OFF supported */
+	case SENSOR_AWB_OFF:
+		break;
+	default:
+		dprintk(1, "AWB not supported,\
+			set to AWB_OFF by default.");
+	}
+
+	switch (config->aec) {
+		/* only SENSOR_AEC_OFF supported */
+	case SENSOR_AEC_OFF:
+		break;
+	default:
+		dprintk(1, "AEC not supported,\
+			set to AEC_OFF by default.");
+	}
+
+	DBG_leaving;
+
+	return err;
+}
+static int s5k4e1_init(struct i2c_client *c)
+{
+	int ret = 0;
+	struct v4l2_subdev *sd = i2c_get_clientdata(c);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	char *name = "";
+
+	DBG_entering;
+
+	/* Fill the configuration structure */
+	/* Note this default configuration value */
+	info->mode = s5k4e1_formats[0].pixelformat;
+	info->res = s5k4e1_res[0].res;
+	info->type = SENSOR_TYPE_RAW;
+	info->bls = SENSOR_BLS_OFF;
+	info->gamma = SENSOR_GAMMA_OFF;
+	info->cconv = SENSOR_CCONV_OFF;
+	info->blc = SENSOR_BLC_AUTO;
+	info->agc = SENSOR_AGC_OFF;
+	info->awb = SENSOR_AWB_OFF;
+	info->aec = SENSOR_AEC_OFF;
+	/*info->bus_width = SENSOR_BUSWIDTH_10BIT_ZZ;*/
+	info->bus_width = SENSOR_BUSWIDTH_12BIT;
+	info->ycseq = SENSOR_YCSEQ_YCBYCR;
+	info->conv422 = SENSOR_CONV422_COSITED;
+	/*info->conv422 = SENSOR_CONV422_NOCOSITED;*/
+	info->bpat = SENSOR_BPAT_GRGRBGBG;
+	info->field_inv = SENSOR_FIELDINV_NOSWAP;
+	info->field_sel = SENSOR_FIELDSEL_BOTH;
+	info->hpol = SENSOR_HPOL_REFPOS;
+	info->vpol = SENSOR_VPOL_NEG;
+	info->edge = SENSOR_EDGE_RISING;
+	info->flicker_freq = SENSOR_FLICKER_100;
+	info->cie_profile = SENSOR_CIEPROF_F11;
+	info->mipi_mode = SENSOR_MIPI_MODE_RAW_10;
+	name = "s5k4e1";
+	memcpy(info->name, name, 7);
+
+	/* Reset sensor hardware, and implement the setting*/
+	ret += s5k4e1_write(c, 0x0100, (u32)0x00);
+	/*TODO: See if we can ignore this*/
+	ret = s5k4e1_write(c, 0x0103, (u32)0x01);
+
+	/* sw reset -- delay 3.1ms */
+	msleep(4);
+
+	/* Set registers into default config value */
+	/* ret += s5k4e1_write_array(c, s5k4e1_def_reg); */
+
+	/* Set MIPI interface */
+#ifdef S5K4E1_MIPI
+	ret += s5k4e1_write_array(c, s5k4e1_mipi);
+#endif
+
+	ret += s5k4e1_set_img_ctrl(c, info); /*FIXME*/
+
+	/* streaming */
+	/* ret += s5k4e1_write(c, 0x0100, (u32)0x01); */
+	ret += s5k4e1_write(c, 0x0100, (u32)0x00);
+
+	msleep(1);
+
+	DBG_leaving;
+
+	return ret;
+}
+
+static int distance(struct s5k4e1_res_struct *res, u32 w, u32 h)
+{
+	int ret;
+
+	DBG_entering;
+
+	if (res->width < w || res->height < h)
+		return -1;
+
+	ret = ((res->width - w) + (res->height - h));
+
+	DBG_leaving;
+
+	return ret;
+}
+
+static int s5k4e1_try_res(u32 *w, u32 *h)
+{
+	struct s5k4e1_res_struct *res_index, *p = NULL;
+	int dis, last_dis = s5k4e1_res->width + s5k4e1_res->height;
+
+	DBG_entering;
+
+	for (res_index = s5k4e1_res;
+	     res_index < s5k4e1_res + N_RES;
+	     res_index++) {
+		if ((res_index->width < *w) || (res_index->height < *h))
+			break;
+		dis = distance(res_index, *w, *h);
+		if (dis < last_dis) {
+			last_dis = dis;
+			p = res_index;
+		}
+	}
+
+	if (p == NULL)
+		p = s5k4e1_res;
+	else if ((p->width < *w) || (p->height < *h)) {
+		if (p != s5k4e1_res)
+			p--;
+	}
+
+	if ((w != NULL) && (h != NULL)) {
+		*w = p->width;
+		*h = p->height;
+	}
+
+	DBG_leaving;
+	return 0;
+}
+
+static struct s5k4e1_res_struct *s5k4e1_to_res(u32 w, u32 h)
+{
+	struct s5k4e1_res_struct *res_index;
+
+	DBG_entering;
+
+	for (res_index = s5k4e1_res;
+	     res_index < s5k4e1_res + N_RES;
+	     res_index++)
+		if ((res_index->width == w) && (res_index->height == h))
+			break;
+
+	if (res_index >= s5k4e1_res + N_RES)
+		res_index--;   /* Take the bigger one */
+
+	DBG_leaving;
+
+	return res_index;
+}
+
+static int s5k4e1_try_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	DBG_entering;
+	return s5k4e1_try_res(&fmt->fmt.pix.width, &fmt->fmt.pix.height);
+	DBG_leaving;
+}
+
+static int s5k4e1_get_fmt(struct v4l2_subdev *sd,
+			  struct v4l2_format *fmt)
+{
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	unsigned short width, height;
+	int index;
+
+	ci_sensor_res2size(info->res, &width, &height);
+
+	/* Marked the current sensor res as being "used" */
+	for (index = 0; index < N_RES; index++) {
+		if ((width == s5k4e1_res[index].width) &&
+		    (height == s5k4e1_res[index].height)) {
+			s5k4e1_res[index].used = 1;
+			continue;
+		}
+		s5k4e1_res[index].used = 0;
+	}
+
+	fmt->fmt.pix.width = width;
+	fmt->fmt.pix.height = height;
+	return 0;
+
+}
+
+#if 0
+/* chuanxiao add, to dump regs */
+static int s5k4e1_dump_regs(struct i2c_client *c)
+{
+	/*struct i2c_client *c = v4l2_get_subdevdata(sd);*/
+	const struct DumpRegs *p = regs_d;
+	u32 value;
+	u32 value1, value2, value3, value4;
+	while (p->ulFlags != eTableEnd) {
+		if (p->ulFlags & eFourBytes) {
+			s5k4e1_read(c, (u32)p->ulAddr, &value1);
+			s5k4e1_read(c, (u32)p->ulAddr+1, &value2);
+			s5k4e1_read(c, (u32)p->ulAddr+2, &value3);
+			s5k4e1_read(c, (u32)p->ulAddr+3, &value4);
+			value = value1<<24 | value2<<16 | value3<<8 | value4;
+		} else if (p->ulFlags & eTwoBytes) {
+			s5k4e1_read(c, (u32)p->ulAddr, &value1);
+			s5k4e1_read(c, (u32)p->ulAddr+1, &value2);
+			value = value1<<8 | value2;
+		} else
+			s5k4e1_read(c, (u32)p->ulAddr, &value);
+		/*
+		if (value == p->ulDefaultValue)
+			dprintk(0, "%s\t @ 0x%x = 0x%lx (= default value)\n",
+			p->pszName, p->ulAddr, value);
+		else
+			dprintk(0, "%s\t @ 0x%x = 0x%lx (default was 0x%lx)\n",
+			p->pszName, p->ulAddr, value, p->ulDefaultValue);
+		*/
+		dprintk(0, "%-30s @ 0x%04X = 0x%08X", p->pszName,
+			p->ulAddr, value);
+		p++;
+	}
+	return 0;
+}
+#endif
+
+static int s5k4e1_set_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
+{
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	struct ci_sensor_config *info = to_sensor_config(sd);
+	int ret = 0;
+	struct s5k4e1_res_struct *res_index;
+	u32 width, height;
+	int index;
+
+	DBG_entering;
+
+	width = fmt->fmt.pix.width;
+	height = fmt->fmt.pix.height;
+
+	dprintk(1, "was told to set fmt (%d x %d) ", width, height);
+	ret = s5k4e1_try_res(&width, &height);
+
+	res_index = s5k4e1_to_res(width, height);
+
+	s5k4e1_wakeup();
+	DBG_line;
+	if (res_index->regs) {
+		/* software sleep/standby */
+		ret += s5k4e1_write(c, 0x0100, (u32)0x00);
+
+		/* Soft reset camera first*/
+		/*TODO: See if we can ignore this*/
+		ret = s5k4e1_write(c, 0x0103, (u32)0xff);
+
+		/* Set registers into default config value */
+		/* ret += s5k4e1_write_array(c, s5k4e1_def_reg);*/
+
+		/* set image resolution */
+		ret += s5k4e1_write_array(c, res_index->regs);
+
+		ret += s5k4e1_set_img_ctrl(c, info);
+
+		/* XXX setup with unknow meaning ... */
+		/* ret += s5k4e1_write(c, 0x30b0, 0xfe); */
+
+		/* Set MIPI interface */
+#ifdef S5K4E1_MIPI
+		ret += s5k4e1_write_array(c, s5k4e1_mipi);
+#endif
+
+		/* streaming */
+		ret = s5k4e1_write(c, 0x0100, (u32)0x01);
+		msleep(1);
+
+		info->res = res_index->res;
+
+		/* Marked current sensor res as being "used" */
+		for (index = 0; index < N_RES; index++) {
+			if ((width == s5k4e1_res[index].width) &&
+			    (height == s5k4e1_res[index].height)) {
+				s5k4e1_res[index].used = 1;
+				continue;
+			}
+			s5k4e1_res[index].used = 0;
+		}
+
+		for (index = 0; index < N_RES; index++)
+			dprintk(2, "index = %d, used = %d\n", index,
+				s5k4e1_res[index].used);
+
+		DBG_line;
+	} else {
+		eprintk("no res for (%d x %d)", width, height);
+	}
+
+	DBG_leaving;
+	return ret;
+}
+
+static int s5k4e1_t_gain(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	DBG_entering;
+
+	s5k4e1_write(client, 0x0104, 1); /*hold*/
+
+	/* analog gain */
+	s5k4e1_write(client, 0x0204, value >> 8);
+
+	s5k4e1_write(client, 0x0205, value & 0xff);
+
+	s5k4e1_write(client, 0x0104, 0); /*unhold*/
+
+	dprintk(1, "gain %x was writen to 0x0204/5", value);
+
+	DBG_leaving;
+	return 0;
+}
+
+static int s5k4e1_t_exposure(struct v4l2_subdev *sd, int value)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	DBG_entering;
+
+	s5k4e1_write(client, 0x0104, 1); /*hold*/
+
+	/* fine integration time */
+	s5k4e1_write(client, 0x0200, value >> 24);
+
+	s5k4e1_write(client, 0x0201, (value >> 16) & 0xff);
+
+	/* coarse integration time */
+	s5k4e1_write(client, 0x0202, (value & 0xff00) >> 8);
+
+	s5k4e1_write(client, 0x0203, value & 0xff);
+
+	s5k4e1_write(client, 0x0104, 0); /*unhold*/
+
+	dprintk(1, "exposure %x was writen to 0x0200/1/2/3", value);
+
+	DBG_leaving;
+	return 0;
+}
+
+static struct s5k4e1_control {
+	struct v4l2_queryctrl qc;
+	int (*query)(struct v4l2_subdev *sd, __s32 *value);
+	int (*tweak)(struct v4l2_subdev *sd, int value);
+} s5k4e1_controls[] = {
+	{
+		.qc = {
+			.id = V4L2_CID_GAIN,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "global gain",
+			.minimum = 0x0,
+			.maximum = 0xFFFF,
+			.step = 0x01,
+			.default_value = 0x00,
+			.flags = 0,
+		},
+		.tweak = s5k4e1_t_gain,
+	},
+	{
+		.qc = {
+			.id = V4L2_CID_EXPOSURE,
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.name = "exposure",
+			.minimum = 0x0,
+			.maximum = 0xFFFF,
+			.step = 0x01,
+			.default_value = 0x00,
+			.flags = 0,
+		},
+		.tweak = s5k4e1_t_exposure,
+	},
+};
+#define N_CONTROLS (ARRAY_SIZE(s5k4e1_controls))
+
+static struct s5k4e1_control *s5k4e1_find_control(__u32 id)
+{
+	int i;
+
+	DBG_entering;
+	for (i = 0; i < N_CONTROLS; i++)
+		if (s5k4e1_controls[i].qc.id == id)
+			return s5k4e1_controls + i;
+	DBG_leaving;
+	return NULL;
+}
+
+static int s5k4e1_queryctrl(struct v4l2_subdev *sd,
+			    struct v4l2_queryctrl *qc)
+{
+	struct s5k4e1_control *ctrl = s5k4e1_find_control(qc->id);
+
+	DBG_entering;
+	if (ctrl == NULL)
+		return -EINVAL;
+	*qc = ctrl->qc;
+
+	DBG_leaving;
+	return 0;
+}
+
+static int s5k4e1_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+/*
+	struct s5k4e1_control *octrl = s5k4e1_find_control(parm->index);
+	int ret;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret = octrl->query(client, &parm->value);
+	if (ret >= 0)
+		return 0;
+*/
+	return 0;
+}
+
+static int s5k4e1_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
+{
+	struct s5k4e1_control *octrl = s5k4e1_find_control(ctrl->id);
+	int ret;
+
+	DBG_entering;
+
+	if (octrl == NULL)
+		return -EINVAL;
+	ret =  octrl->tweak(sd, ctrl->value);
+	if (ret >= 0)
+		return 0;
+
+	DBG_leaving;
+	return ret;
+}
+
+static int s5k4e1_s_stream(struct v4l2_subdev *sd, int enable)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	DBG_entering;
+
+	if (enable) {
+		s5k4e1_write(client, (u32)0x0100, 0x01);
+		/*chuanxiao add, dump s5k4e1 regs*/
+		/* s5k4e1_dump_regs(client); */
+	} else
+		s5k4e1_write(client, (u32)0x0100, 0x00);
+
+	/*msleep(1);*/
+
+	DBG_leaving;
+	return 0;
+}
+
+static int s5k4e1_enum_framesizes(struct v4l2_subdev *sd,
+				  struct v4l2_frmsizeenum *fsize)
+{
+	unsigned int index = fsize->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+	fsize->discrete.width = s5k4e1_res[index].width;
+	fsize->discrete.height = s5k4e1_res[index].height;
+	fsize->reserved[0] = s5k4e1_res[index].used;
+
+	DBG_leaving;
+
+	return 0;
+}
+
+static int s5k4e1_enum_frameintervals(struct v4l2_subdev *sd,
+				      struct v4l2_frmivalenum *fival)
+{
+	unsigned int index = fival->index;
+
+	DBG_entering;
+
+	if (index >= N_RES)
+		return -EINVAL;
+
+	fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+	fival->discrete.numerator = 1;
+	fival->discrete.denominator = s5k4e1_res[index].fps;
+
+	DBG_leaving;
+
+	return 0;
+}
+
+static int s5k4e1_g_chip_ident(struct v4l2_subdev *sd,
+		struct v4l2_dbg_chip_ident *chip)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	DBG_entering;
+
+#define V4L2_IDENT_S5K4E1 8250
+	DBG_leaving;
+
+	return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_S5K4E1, 0);
+}
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int s5k4e1_g_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+	unsigned char val = 0;
+	int ret;
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	ret = s5k4e1_read(client, reg->reg & 0xffff, &val);
+	reg->val = val;
+	reg->size = 1;
+	return ret;
+}
+
+static int s5k4e1_s_register(struct v4l2_subdev *sd,
+			     struct v4l2_dbg_register *reg)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+	if (!v4l2_chip_match_i2c_client(client, &reg->match))
+		return -EINVAL;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	s5k4e1_write(client, reg->reg & 0xffff, reg->val & 0xff);
+	return 0;
+}
+#endif
+
+static const struct v4l2_subdev_video_ops s5k4e1_video_ops = {
+	.try_fmt = s5k4e1_try_fmt,
+	.s_fmt = s5k4e1_set_fmt,
+	.g_fmt = s5k4e1_get_fmt,
+	.s_stream = s5k4e1_s_stream,
+	.enum_framesizes = s5k4e1_enum_framesizes,
+	.enum_frameintervals = s5k4e1_enum_frameintervals,
+};
+
+static const struct v4l2_subdev_core_ops s5k4e1_core_ops = {
+	.g_chip_ident = s5k4e1_g_chip_ident,
+	.queryctrl = s5k4e1_queryctrl,
+	.g_ctrl = s5k4e1_g_ctrl,
+	.s_ctrl = s5k4e1_s_ctrl,
+	.s_gpio = s5k4e1_s_power,
+	/*.g_ext_ctrls = s5k4e1_g_ext_ctrls,*/
+	/*.s_ext_ctrls = s5k4e1_s_ext_ctrls,*/
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+	.g_register = s5k4e1_g_register,
+	.s_register = s5k4e1_s_register,
+#endif
+};
+
+static const struct v4l2_subdev_ops s5k4e1_ops = {
+	.core = &s5k4e1_core_ops,
+	.video = &s5k4e1_video_ops,
+};
+
+/*
+ * Basic i2c stuff
+ */
+/*
+static unsigned short normal_i2c[] = {0x36, I2C_CLIENT_END};
+I2C_CLIENT_INSMOD;
+
+static struct i2c_driver i2c_driver_s5k4e1_sensor;
+*/
+static int s5k4e1_detect(struct i2c_client *client)
+{
+	struct i2c_adapter *adapter = client->adapter;
+	int adap_id = i2c_adapter_id(adapter);
+	u32 value;
+
+	DBG_entering;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
+		eprintk("error i2c check func");
+		return -ENODEV;
+	}
+
+	if (adap_id != 1) {
+		eprintk("adap_id != 1");
+		return -ENODEV;
+	}
+
+	if (s5k4e1_wakeup()) {
+		eprintk("sensor wakeup failed");
+		return -EIO;
+	}
+
+	s5k4e1_read(client, 0x0003, &value);
+	dprintk(1, "Read from 0x0003: %x", value);
+	if ((value != 0x09))
+		return -ENODEV;
+
+	s5k4e1_read(client, 0x0000, &value);
+	dprintk(1, "Read from 0x0000: %x", value);
+	if ((value != 0x4e) && (value != 0x10))
+		return -ENODEV;
+
+	s5k4e1_read(client, 0x0001, &value);
+	dprintk(1, "Read from 0x0001: %x", value);
+	if ((value != 0x4e) && (value != 0x10))
+		return -ENODEV;
+
+	/*TODO EVT3 detect*/
+	s5k4e1_read(client, 0x0002, &value);
+	dprintk(1, "Read from 0x0002: %x", value);
+	if (value == 0x0010) {
+		dprintk(1, "EVT3 module not supported!");
+		return -ENODEV;
+	}
+
+	DBG_leaving;
+	return 0;
+}
+
+static int s5k4e1_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	struct ci_sensor_config *info;
+	struct v4l2_subdev *sd;
+	int ret = -1;
+
+	DBG_entering;
+
+	v4l_info(client, "chip found @ 0x%x (%s)\n",
+		 client->addr << 1, client->adapter->name);
+
+	/*
+	 * Setup sensor configuration structure
+	 */
+	info = kzalloc(sizeof(struct ci_sensor_config), GFP_KERNEL);
+	if (!info) {
+		dprintk(0, "fail to malloc for ci_sensor_config");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = s5k4e1_detect(client);
+	if (ret) {
+		dprintk(0, "error s5k4e1_detect");
+		goto out_free;
+	}
+
+	sd = &info->sd;
+	v4l2_i2c_subdev_init(sd, client, &s5k4e1_ops);
+
+	/*
+	 * Initialization S5K4E1
+	 * then turn into standby mode
+	 */
+	ret = s5k4e1_init(client);
+	if (ret) {
+		dprintk(0, "error calling s5k4e1_init");
+		goto out_free;
+	}
+
+	s5k4e1_standby();
+	dprintk(0, "Init s5k4e1 sensor successfully");
+
+	ret = 0;
+	goto out;
+
+out_free:
+	kfree(info);
+	DBG_leaving;
+out:
+
+	DBG_leaving;
+	return ret;
+}
+
+
+static int s5k4e1_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+	DBG_entering;
+
+	v4l2_device_unregister_subdev(sd);
+	kfree(to_sensor_config(sd));
+
+	DBG_leaving;
+	return 0;
+}
+
+/**
+ * i2c_driver for s5k4e1_sensor
+ */
+static const struct i2c_device_id s5k4e1_id[] = {
+	{"s5k4e1", 0},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, s5k4e1_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = "s5k4e1",
+	.probe = s5k4e1_probe,
+	.remove = s5k4e1_remove,
+	/* .suspend = s5k4e1_suspend,
+	 * .resume = s5k4e1_resume, */
+	.id_table = s5k4e1_id,
+};
+
+MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
+MODULE_DESCRIPTION("A low-level driver for Samsung S5K4E1 sensors");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.h b/drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.h
new file mode 100755
index 0000000..d722035
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1/mrsts5k4e1.h
@@ -0,0 +1,662 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#define I2C_S5K4E1	0x6C
+/* Should add to kernel source */
+#define I2C_DRIVERID_S5K4E1	1046
+/* GPIO pin on Moorestown */
+#define GPIO_SCLK_25	44
+#define GPIO_STB_PIN	47
+#define GPIO_STDBY_PIN	49
+#define GPIO_RESET_PIN	50
+
+struct regval_list {
+	u16 reg_num;
+	u8 value;
+};
+
+/*
+ * Default register value
+ * 5Mega Pixel, 2592x1944
+ */
+/* MIPI register are removed by Wen */
+
+/* 2592x1944 */
+static struct regval_list s5k4e1_res_qsxga_plus4[] = {
+	/* Reset for operation */
+	{0x0100, 0x00},		/* stream off */
+	{0x0103, 0x01}, 	/* software reset */
+
+/*
+ * Analog Setting
+ * This register is for FACTORY ONLY.
+ * If you change it without prior notification,
+ * You are RESPONSIBLE for the FAILURE that will happen in the future.
+ */
+
+/* CDS timing setting ... */
+	{0x3000, 0x04},	/* ct_ld_start (default = 07h) */
+	{0x3001, 0x02},	/* ct_sl_start (default = 05h) */
+	{0x3002, 0x0C},	/* ct_rx_start (default = 21h) */
+	{0x3003, 0x0E},	/* ct_cds_start (default = 23h) */
+	{0x3004, 0x2C},	/* ct_smp_width (default = 60h) */
+	{0x3005, 0x0D},	/* ct_az_width (default = 28h) */
+	{0x3006, 0x39},	/* ct_s1r_width (default = 88h) */
+	{0x3007, 0x02},	/* ct_tx_start (default = 06h) */
+	{0x3008, 0x3C},	/* ct_tx_width 1.5us (default = 7Ch) */
+	{0x3009, 0x3C},	/* ct_stx_width 1.5us (default = 7Ch) */
+	{0x300A, 0x28},	/* ct_dtx_width 1us (default = 3Eh) */
+	{0x300B, 0x15},	/* ct_rmp_rst_start (default = 44h) */
+	{0x300C, 0x15},	/* ct_rmp_sig_start (default = 48h) */
+	{0x300D, 0x02},	/* ct_rmp_lat (default = 02h) */
+	{0x300E, 0xA9},	/* D-Shut en[7], CLP On[5], LD high[4] */
+
+/* CDS option setting ... */
+	{0x3010, 0x00},	/* smp_en[2]=0(00) 1(04) row_id[1:0] = 00 */
+	{0x3011, 0x7A},	/* RST_MX (288), SIG_MX (1024+352) */
+	{0x3012, 0x30},	/* SIG offset1  48 code  */
+	{0x3013, 0xA0},	/* RST offset1  160 code */
+	{0x3014, 0x00},	/* SIG offset2 */
+	{0x3015, 0x00},	/* RST offset2 */
+	{0x3016, 0x02},	/* ADC_SAT (510mV) */
+	{0x3017, 0x94},	/* RMP_INIT[3:0](RMP_REG) 1.8V MS[6:4]=1 */
+	{0x3018, 0x78},	/* rmp option - ramp connect[MSB] +RMP INIT DAC MIN */
+	{0x301D, 0xD4},	/* CLP level (default = 0Fh) */
+
+	{0x3021, 0x02},	/* inrush ctrl[1] off */
+	{0x3022, 0x44},	/* pump ring oscillator set [7:4]=CP, [3:0]=NCP  */
+	{0x3024, 0x40},	/* pix voltage 2.8V   (default = 88h) */
+	{0x3027, 0x08},	/* ntg voltage (default = 04h) */
+
+/* Pixel option setting ... */
+	{0x301C, 0x05},	/* Pixel Bias [3:0] (default = 03h) */
+	{0x30D8, 0x3F},	/* All tx off 2f, on 3f */
+
+/* ADLC setting ... */
+	{0x3070, 0x5F},	/* [6]L-ADLC BPR, [4]ch sel, [3]L-ADLC, [2]F-ADLC */
+	{0x3071, 0x00},	/* F&L-adlc max 127 (default = 11h, max 255) */
+	{0x3080, 0x04},	/* F-ADLC filter A (default = 10h) */
+	{0x3081, 0x38},	/* F-ADLC filter B (default = 20h) */
+
+/* Integration setting ... */
+	{0x0202, 0x03},	/* coarse integration time */
+	{0x0203, 0xCF},
+	{0x0204, 0x00},	/* analog gain[msb] 0100 x8 0080 x4 */
+	{0x0205, 0x80},	/* analog gain[lsb] 0040 x2 0020 x1 */
+
+/* Frame Length */
+	{0x0340, 0x07},	/* Capture 07B4(1960[# of row]+12[V-blank]) */
+	{0x0341, 0xA4},	/* Preview 03E0(980[# of row]+12[V-blank]) */
+
+/* Line Length */
+	{0x0342, 0x0A}, /* 2738 */
+	{0x0343, 0xB2},	/* (Same as sensor default) */
+
+/* embedded 2-line OFF setting ... */
+/* 2608 x 1960  */
+	{0x3084, 0x15},	/* SYNC Mode */
+
+/* (3) MIPI 2-lane Serial(TST = 0000b or TST = 0010b), 30 fps */
+
+	{0x30A9, 0x01},
+	{0x0387, 0x01},
+
+	{0x30BD, 0x00},		/* SEL_CCP[0] */
+	{0x30B2, 0x08},		/* PLL P = 8 */
+	{0x30B3, 0x00},		/* PLL M[8] = 0 */
+	{0x30B5, 0x01},		/* PLL S = 0 */
+	{0x30BE, 0x1A},		/* M_PCLKDIV_AUTO[4], M_DIV_PCLK[3:0] */
+
+	{0x30BF, 0xAB},
+	{0x30C0, 0x00},		/* video_offset[7:4] 3240%12 */
+	{0x30C1, 0x01},		/* pack video enable [0] */
+	{0x30C8, 0x0C},		/* video_data_length 3260 = 2608 * 1.25 */
+	{0x30C9, 0xA8},
+	{0x30E2, 0x02},		/* num lanes[1:0] = 2 */
+	{0x30EE, 0x02},		/* DPHY enable [1] */
+	{0x30F1, 0x70},		/* DPHY BANDCTRL 800MHz=80.6MHz */
+	{0x3111, 0x86},		/* Embedded data off [5] */
+
+	{0x034C, 0x0A},
+	{0x034D, 0x20},
+	{0x044E, 0x07},
+	{0x034F, 0x98},
+
+	{0x0344, 0x00},
+	{0x0345, 0x08},
+	{0x0346, 0x00},
+	{0x0347, 0x08},
+	{0x0348, 0x0A},
+	{0x0349, 0x27},
+	{0x034A, 0x07},
+	{0x034B, 0x9F},
+
+	/* This is to set FRAME_NUM > 0 */
+	{0x30d9, 0x00},
+
+	/* Add this setting according to Bill's test */
+	{0x0305, 0x05},
+	{0x0306, 0x00},
+	{0x0307, 0x3c},
+	{0x30b5, 0x02},
+
+	{0x020E, 0x01},      /* Gr Digital Gain */
+	{0x020F, 0x00},
+	{0x0210, 0x01},     /* Red Digital Gain */
+	{0x0211, 0x00},
+	{0x0212, 0x01},     /* Blue Digital Gain */
+	{0x0213, 0x00},
+	{0x0214, 0x01},    /* Gb Digital Gain */
+	{0x0215, 0x00},
+	{0x0204, 0x00},
+	{0x0205, 0x80},
+
+#if 1
+	/*Apply Bill's setting*/
+	{0x30E2, 0x02},
+	{0x0305, 0x05},
+	{0x0306, 0x00},
+	{0x0307, 0x50},		/* vcc_out = 80 */
+	{0x30B5, 0x01},		/* pll_s = 1 */
+	{0x30B4, 0x50},
+
+	{0x30B2, 0x05},
+
+	{0x30BE, 0x1A},		/* DIV_M_PCLK = 5 */
+
+	{0x0100, 0x01},		/* stream on */
+	{0xffff, 0xff},
+#endif
+};
+
+/* 1920x1080 */
+static struct regval_list s5k4e1_res_1080p[] = {
+/* Reset for operation ... */
+	{0x0100, 0x00},		/* stream off */
+	{0x0103, 0x01}, 	/* software reset */
+
+/*
+ * Analog Setting
+ * This register is for FACTORY ONLY.
+ * If you change it without prior notification,
+ * You are RESPONSIBLE for the FAILURE that will happen in the future.
+ */
+
+/* CDS timing setting ... */
+	{0x3000, 0x04},	/* ct_ld_start (default = 07h) */
+	{0x3001, 0x02},	/* ct_sl_start (default = 05h) */
+	{0x3002, 0x0C},	/* ct_rx_start (default = 21h) */
+	{0x3003, 0x0E},	/* ct_cds_start (default = 23h) */
+	{0x3004, 0x2C},	/* ct_smp_width (default = 60h) */
+	{0x3005, 0x0D},	/* ct_az_width (default = 28h) */
+	{0x3006, 0x39},	/* ct_s1r_width (default = 88h) */
+	{0x3007, 0x02},	/* ct_tx_start (default = 06h) */
+	{0x3008, 0x3C},	/* ct_tx_width 1.5us (default = 7Ch) */
+	{0x300A, 0x28},	/* ct_dtx_width 1us (default = 3Eh) */
+	{0x300B, 0x15},	/* ct_rmp_rst_start (default = 44h) */
+	{0x300C, 0x15},	/* ct_rmp_sig_start (default = 48h) */
+	{0x300D, 0x02},	/* ct_rmp_lat (default = 02h) */
+	{0x300E, 0xA9},	/* D-Shut en[7], CLP On[5], LD high[4] */
+
+/* CDS option setting ... */
+	{0x3010, 0x00},	/* smp_en[2]=0(00) 1(04) row_id[1:0] = 00 */
+	{0x3011, 0x7A},	/* RST_MX (288), SIG_MX (1024+352) */
+	{0x3012, 0x30},	/* SIG offset1  48 code */
+	{0x3013, 0xA0},	/* RST offset1  160 code */
+	{0x3014, 0x00},	/* SIG offset2 */
+	{0x3015, 0x00},	/* RST offset2 */
+	{0x3016, 0x0A},	/* ADC_SAT (510mV) */
+	{0x3017, 0x94},	/* RMP_INIT[3:0](RMP_REG) 1.8V MS[6:4]=1 */
+	{0x3018, 0x78},	/* rmp option - ramp connect[MSB] +RMP INIT DAC MIN */
+
+	{0x301D, 0xD4},	/* CLP level (default = 0Fh) */
+
+	{0x3021, 0x02},	/* inrush ctrl[1] off */
+	{0x3022, 0x41},	/* pump ring oscillator set [7:4]=CP, [3:0]=NCP */
+	{0x3024, 0x08},	/* pix voltage 2.8V   (default = 88h) */
+	{0x3027, 0x08},	/* ntg voltage (default = 04h) */
+
+/* Pixel option setting ... */
+	{0x301C, 0x05},	/* Pixel Bias [3:0] (default = 03h) */
+	{0x30D8, 0x3F},	/* All tx off 2f, on 3f */
+
+/* ADLC setting ... */
+	{0x3070, 0x5F},	/* [6]L-ADLC BPR, [4]ch sel, [3]L-ADLC, [2]F-ADLC */
+	{0x3071, 0x00},	/* F&L-adlc max 127 (default = 11h, max 255) */
+	{0x3080, 0x04},	/* F-ADLC filter A (default = 10h) */
+	{0x3081, 0x38},	/* F-ADLC filter B (default = 20h) */
+
+/* Integration setting ... */
+	{0x0202, 0x03},	/* coarse integration time */
+	{0x0203, 0xCD},
+	{0x0204, 0x00},	/* analog gain[msb] 0100 x8 0080 x4 */
+	{0x0205, 0x80},	/* analog gain[lsb] 0040 x2 0020 x1 */
+
+/* Frame Length */
+	{0x0340, 0x04},	/*Capture 07B4(1960[# of row]+12[V-blank]) */
+	{0x0341, 0x44},	/*Preview 03E0(980[# of row]+12[V-blank]) */
+
+/* Line Length */
+	{0x0342, 0x0A}, /* 2738 */
+	{0x0343, 0xB2},	/*(Same as sensor default) */
+
+/* embedded 2-line OFF setting ... */
+/* 1920 x 1080 */
+	{0x3084, 0x15},	/* SYNC Mode */
+
+/* PLL & MIPI setting ... */
+/* input clock 25MHz */
+
+/* (3) MIPI 2-lane Serial(TST = 0000b or TST = 0010b), 30 fps */
+	{0x30BD, 0x00},		/* SEL_CCP[0] */
+	{0x30B2, 0x08},		/* PLL P = 8 */
+	{0x30B3, 0x00},		/* PLL M[8] = 0 */
+	{0x30B4, 0x78},		/* PLL M = 129 */
+	{0x30B5, 0x00},		/* PLL S = 0 */
+	{0x30BE, 0x1A},		/* M_PCLKDIV_AUTO[4], M_DIV_PCLK[3:0] */
+
+	{0x30BF, 0xAB},
+	{0x30C0, 0x00},		/* video_offset[7:4] 2400%12 */
+	{0x30C1, 0x01},		/* pack video enable [0] */
+	{0x30C8, 0x09},		/* video_data_length 2400 = 1920 * 1.25 */
+	{0x30C9, 0x60},
+	{0x30E2, 0x02},		/* num lanes[1:0] = 2 */
+	{0x30EE, 0x02},		/* DPHY enable [1] */
+	{0x30F1, 0x70},		/* DPHY BANDCTRL 800MHz=80.6MHz */
+	{0x3111, 0x86},		/* Embedded data off [5] */
+
+	{0x30b4, 0x20},
+	{0x30b5, 0x01},
+
+	{0x30A9, 0x01},
+	{0x0387, 0x01},
+	{0x0344, 0x01},	/*x_addr_start 344 */
+	{0x0345, 0x58},
+	{0x0348, 0x08},	/*x_addr_end 2263 */
+	{0x0349, 0xD7},
+	{0x0346, 0x01},	/*y_addr_start 440 */
+	{0x0347, 0xB8},
+	{0x034A, 0x05},	/*y_addr_end 1519 */
+	{0x034B, 0xEF},
+
+	{0x034C, 0x07},	/*x_output_size 1920 */
+	{0x034D, 0x80},
+	{0x034E, 0x04},	/*y_output_size 1080 */
+	{0x034F, 0x38},
+
+	{0x30d9, 0x00},
+
+	{0x020E, 0x01},      /*Gr Digital Gain */
+	{0x020F, 0x00},
+	{0x0210, 0x01},     /*Red Digital Gain */
+	{0x0211, 0x00},
+	{0x0212, 0x01},     /*Blue Digital Gain */
+	{0x0213, 0x00},
+	{0x0214, 0x01},    /*Gb Digital Gain */
+	{0x0215, 0x00},
+	{0x0204, 0x00},
+	{0x0205, 0x80},
+
+
+	/*Apply Bill's setting*/
+	{0x30E2, 0x02},
+	{0x0305, 0x05},
+	{0x0306, 0x00},
+	{0x0307, 0x50},		/*vcc_out = 80 */
+	{0x30B5, 0x01},		/*pll_s = 1 */
+	{0x30B4, 0x50},
+
+	{0x30B2, 0x05},
+
+	{0x30BE, 0x1A},		/*DIV_M_PCLK = 5 */
+
+	{0x0383, 0x01},
+
+	{0x0100, 0x01},		/* stream on */
+	{0xffff, 0xff},
+
+};
+
+/* 1280x720, V1F2 & H1F2 */
+static struct regval_list s5k4e1_res_720p[] = {
+	{0x0100, 0x00},		/* stream off */
+	{0x0103, 0x01}, 	/* software reset */
+
+/* CDS timing setting ... */
+	{0x3000, 0x04},
+	{0x3001, 0x02},
+	{0x3002, 0x0C},
+	{0x3003, 0x0E},
+	{0x3004, 0x2C},
+	{0x3005, 0x0D},
+	{0x3006, 0x39},
+	{0x3007, 0x02},
+	{0x3008, 0x3C},
+	{0x3009, 0x3C},
+	{0x300A, 0x28},
+	{0x300B, 0x15},
+	{0x300C, 0x15},
+	{0x300D, 0x02},
+	{0x300E, 0xAB},
+
+/* CDS option setting ... */
+	{0x3010, 0x00},
+	{0x3011, 0x7A},
+	{0x3012, 0x30},
+	{0x3013, 0x90},
+	{0x3014, 0x00},
+	{0x3015, 0x00},
+	{0x3016, 0x0A},
+	{0x3017, 0x84},
+	{0x3018, 0x78},
+	{0x301D, 0xD4},
+
+	{0x3021, 0x02},
+	{0x3022, 0x41},
+	{0x3024, 0x08},
+	{0x3027, 0x08},
+
+/* Pixel option setting ... */
+	{0x301C, 0x05},	/* Pixel Bias [3:0] (default = 03h) */
+	{0x30D8, 0x3F},	/* All tx off 2f, on 3f */
+
+/* ADLC setting ... */
+	{0x3070, 0x5F},
+	{0x3071, 0x00},
+	{0x3080, 0x04},
+	{0x3081, 0x38},
+
+/* Integration setting ...  */
+	{0x0202, 0x03},
+	{0x0203, 0xD8},
+	{0x0204, 0x00},
+	{0x0205, 0x80},
+
+/*Frame Length*/
+	{0x0340, 0x02},
+	{0x0341, 0xDC},
+
+/* Line Length */
+	{0x0342, 0x0A}, /*2738 */
+	{0x0343, 0xB2},
+
+/* Average Sub-sampling */
+	{0x0387, 0x03},
+	{0x30a9, 0x02},
+
+/* embedded 2-line OFF setting ... */
+/* 1280 x 720 */
+	{0x3084, 0x15},
+
+/* PLL & MIPI setting ... */
+
+/* (3) MIPI 2-lane Serial(TST = 0000b or TST = 0010b), 60 fps */
+	{0x30BD, 0x00},
+	{0x30B2, 0x08},
+	{0x30B3, 0x00},
+	{0x30B4, 0x78},
+	{0x30B5, 0x00},
+	{0x30BE, 0x1A},
+
+	{0x30BF, 0xAB},
+	{0x30C0, 0x40},
+	{0x30C1, 0x01},
+	{0x30C8, 0x06},
+	{0x30C9, 0x40},
+
+	{0x30E2, 0x02},
+
+	{0x30b4, 0x20},
+	{0x30b5, 0x01},
+
+	{0x30EE, 0x02},
+	{0x30F1, 0x70},
+	{0x3111, 0x86},
+
+/* MIPI Size Setting ... */
+/* 1304 x 980 */
+	{0x0344, 0x00},
+	{0x0345, 0x18},
+	{0x0348, 0x0A},
+	{0x0349, 0x17},
+	{0x0346, 0x01},
+	{0x0347, 0x04},
+	{0x034A, 0x06},
+	{0x034B, 0xA3},
+
+	{0x0380, 0x00},
+	{0x0381, 0x01},
+	{0x0382, 0x00},
+	{0x0383, 0x01},
+	{0x0384, 0x00},
+	{0x0385, 0x01},
+	{0x0386, 0x00},
+	{0x0387, 0x03},
+
+	{0x034C, 0x05}, /* x_output_size = 1280 */
+	{0x034D, 0x00},
+	{0x034E, 0x02}, /* y_output_size = 720 */
+	{0x034F, 0xD0},
+
+	{0x30d9, 0x00},
+
+	{0x020E, 0x01},
+	{0x020F, 0x00},
+	{0x0210, 0x01},
+	{0x0211, 0x00},
+	{0x0212, 0x01},
+	{0x0213, 0x00},
+	{0x0214, 0x01},
+	{0x0215, 0x00},
+	{0x0204, 0x01},
+	{0x0205, 0x00},
+
+	/*Apply Bill's setting*/
+	{0x30E2, 0x02},
+	{0x0305, 0x05},
+	{0x0306, 0x00},
+	{0x0307, 0x50},		/*vcc_out = 80 */
+	{0x30B5, 0x01},		/*pll_s = 1 */
+	{0x30B4, 0x50},
+
+	{0x30B2, 0x05},
+
+	{0x30BE, 0x15},		/*DIV_M_PCLK = 5 */
+
+	{0x0100, 0x01},		/* stream on */
+	{0xffff, 0xff},
+};
+
+/*VGA*/
+static struct regval_list s5k4e1_res_vga_ac04_bill[] = {
+	{0x0100, 0x00},		/* stream off */
+	{0x0103, 0x01}, 	/* software reset */
+
+	{0x3000, 0x04},
+	{0x3001, 0x02},
+	{0x3002, 0x0C},
+	{0x3003, 0x0E},
+	{0x3004, 0x2C},
+	{0x3005, 0x0D},
+	{0x3006, 0x39},
+	{0x3007, 0x02},
+	{0x3008, 0x3C},
+	{0x3009, 0x3C},
+	{0x300A, 0x28},
+	{0x300B, 0x15},
+	{0x300C, 0x15},
+	{0x300D, 0x02},
+	{0x300E, 0xA8},
+
+	{0x3010, 0x00},
+	{0x3011, 0x7A},
+	{0x3012, 0x30},
+	{0x3013, 0xA0},
+	{0x3014, 0x00},
+	{0x3015, 0x00},
+	{0x3016, 0x0A},
+	{0x3017, 0x94},
+	{0x3018, 0x78},
+
+	{0x301D, 0xD4},
+
+	{0x3021, 0x02},
+	{0x3022, 0x41},
+	{0x3024, 0x08},
+	{0x3027, 0x08},
+
+	{0x301C, 0x05},
+	{0x30D8, 0x3F},
+
+	{0x3070, 0x5F},
+	{0x3071, 0x00},
+	{0x3080, 0x04},
+	{0x3081, 0x38},
+
+	{0x0202, 0x03},
+	{0x0203, 0xD4},
+	{0x0204, 0x00},
+	{0x0205, 0x20},
+
+	{0x0340, 0x03},
+	{0x0341, 0xE0},
+
+	{0x0342, 0x0A},
+	{0x0343, 0xB2},
+
+	{0x0344, 0x00},
+	{0x0345, 0x18},
+	{0x0348, 0x0A},
+	{0x0349, 0x17},
+	{0x0346, 0x00},
+	{0x0347, 0x14},
+	{0x034A, 0x07},
+	{0x034B, 0x93},
+
+	{0x034C, 0x02},
+	{0x034D, 0x80},
+	{0x034E, 0x01},
+	{0x034F, 0xE0},
+
+	{0x0380, 0x00},
+	{0x0381, 0x01},
+	{0x0382, 0x00},
+	{0x0383, 0x07},
+	{0x0384, 0x00},
+	{0x0385, 0x01},
+	{0x0386, 0x00},
+	{0x0387, 0x07},
+
+	{0x3084, 0x15},
+
+	{0x30BD, 0x00},
+
+
+	{0x30b3, 0x00},
+	{0x30b4, 0x57},
+	{0x30b5, 0x01},
+	{0x30f1, 0x70},
+
+	{0x30BE, 0x1A},
+
+	{0x30BF, 0xAB},
+	{0x30C0, 0x80},
+	{0x30C1, 0x01},
+	{0x30C8, 0x03},
+	{0x30C9, 0x20},
+
+	{0x30b2, 0x06},
+	{0x30E2, 0x02},
+
+	{0x30EE, 0x02},
+
+	{0x3111, 0x86},
+
+	{0x30d9, 0x00},
+
+	{0x020E, 0x01},
+	{0x020F, 0x00},
+	{0x0210, 0x01},
+	{0x0211, 0x00},
+	{0x0212, 0x01},
+	{0x0213, 0x00},
+	{0x0214, 0x01},
+	{0x0215, 0x00},
+	{0x0204, 0x01},
+	{0x0205, 0x00},
+
+#if 1
+	/* Apply Bill's setting */
+	{0x30E2, 0x02},
+	{0x0305, 0x05},
+	{0x0306, 0x00},
+	{0x0307, 0x50},
+	{0x30B5, 0x01},
+	{0x30B4, 0x50},
+
+	{0x30B2, 0x05},
+
+	{0x30BE, 0x15},
+
+	/* {0x0100, 0x01}, */
+	/* {0xffff, 0xff}, */
+#endif
+
+#if 1
+	/* 1304x980 */
+	{0x3013, 0x90},
+	{0x3017, 0x84},
+	{0x30A9, 0x02},
+	{0x300E, 0xAB},
+
+	{0x0387, 0x03},
+	{0x0344, 0x00}, /* x_addr_start = 0 */
+	{0x0345, 0x00},
+	{0x0348, 0x0A}, /* x_addr_end = 2607 */
+	{0x0349, 0x2F},
+	{0x0346, 0x00}, /* y_addr_start = 0 */
+	{0x0347, 0x00},
+	{0x034A, 0x07}, /* y_addr_end = 1959 */
+	{0x034B, 0xA7},
+	{0x0380, 0x00},
+	{0x0381, 0x01},
+	{0x0382, 0x00},
+	{0x0383, 0x01},
+	{0x0384, 0x00},
+	{0x0385, 0x01},
+	{0x0386, 0x00},
+	{0x0387, 0x03},
+	{0x034c, 0x05}, /* x_output_size = 1304 */
+	{0x034d, 0x18},
+	{0x034e, 0x03}, /* y_output_size = 980 */
+	{0x034f, 0xd4},
+	{0x30BF, 0xAB},
+	{0x30c0, 0xa0},
+	{0x30C8, 0x06}, /* x_output_size * 1.25 */
+	{0x30c9, 0x5e},
+
+	{0x0100, 0x01},
+	{0xffff, 0xff},
+
+#endif
+};
diff --git a/drivers/media/video/mrstci/mrsts5k4e1_motor/Kconfig b/drivers/media/video/mrstci/mrsts5k4e1_motor/Kconfig
new file mode 100755
index 0000000..27cb730
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1_motor/Kconfig
@@ -0,0 +1,9 @@
+config VIDEO_MRST_S5K4E1_MOTOR
+	tristate "Moorestown s5k4e1 motor"
+	depends on I2C && VIDEO_MRST_ISP && VIDEO_MRST_S5K4E1
+
+	---help---
+	  Say Y here if your platform support s5k4e1 motor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mrstov2650.ko.
diff --git a/drivers/media/video/mrstci/mrsts5k4e1_motor/Makefile b/drivers/media/video/mrstci/mrsts5k4e1_motor/Makefile
new file mode 100644
index 0000000..68c9fbc
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1_motor/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_VIDEO_MRST_S5K4E1_MOTOR)	 += mrsts5k4e1_motor.o
+
+EXTRA_CFLAGS	+=	-I$(src)/../include
diff --git a/drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.c b/drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.c
new file mode 100644
index 0000000..cd2813b
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.c
@@ -0,0 +1,430 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-i2c-drv.h>
+
+#include "mrsts5k4e1_motor.h"
+
+static int s5k4e1_motor_debug;
+module_param(s5k4e1_motor_debug, int, 0644);
+MODULE_PARM_DESC(s5k4e1_motor_debug, "Debug level (0-1)");
+
+#define dprintk(level, fmt, arg...) \
+    do {			\
+	if (s5k4e1_motor_debug >= level) \
+		printk(KERN_DEBUG "mrstisp@%s: " fmt "\n", __func__, ## arg); \
+    } while (0)
+
+#define eprintk(fmt, arg...)	\
+	printk(KERN_ERR "mrstisp@%s: line %d: " fmt "\n",	\
+	       __func__, __LINE__, ## arg);
+
+#define DBG_entering	dprintk(1, "entering");
+#define DBG_leaving	dprintk(1, "leaving");
+#define DBG_line	dprintk(1, " line: %d", __LINE__);
+
+static inline struct s5k4e1_motor *to_motor_config(struct v4l2_subdev *sd)
+{
+	return container_of(sd, struct s5k4e1_motor, sd);
+}
+
+/*static struct s5k4e1_motor *config; */
+static int motor_read(struct i2c_client *c, u32 *reg)
+{
+	int ret;
+	struct i2c_msg msg;
+	u8 msgbuf[3];
+
+	msgbuf[0] = 0;
+	msgbuf[1] = 0;
+	msgbuf[2] = 0;
+
+	memset(&msg, 0, sizeof(msg));
+	msg.addr = c->addr;
+	msg.buf = msgbuf;
+	msg.len = 3;
+	msg.flags = I2C_M_RD;
+
+	ret = i2c_transfer(c->adapter, &msg, 1);
+
+	*reg = (msgbuf[0] << 16 | msgbuf[1] << 8 | msgbuf[2]);
+
+	ret = (ret == 1) ? 0 : -1;
+	return ret;
+}
+
+static int motor_write(struct i2c_client *c, u32 reg)
+{
+	int ret;
+	struct i2c_msg msg;
+	u8 msgbuf[3];
+
+	memset(&msg, 0, sizeof(msg));
+	msgbuf[0] = (reg & 0x00FFFFFFFF) >> 16;
+	msgbuf[1] = (reg & 0x0000FFFF) >> 8 ;
+	msgbuf[2] = reg;
+
+	msg.addr = c->addr;
+	msg.flags = 0;
+	msg.buf = msgbuf;
+	msg.len = 3;
+
+	ret = i2c_transfer(c->adapter, &msg, 1);
+
+	ret = (ret == 1) ? 0 : -1;
+	return ret;
+}
+
+static int s5k4e1_motor_goto_position(struct i2c_client *c,
+				      unsigned short code,
+				      struct s5k4e1_motor *config,
+				      unsigned int step)
+{
+	int max_code, min_code;
+	int timeout = 25; /*TODO: check the timeout time */
+	u8 cmdh, cmdl, finished;
+	u32 cmd = 0, val = 0;
+
+	max_code = config->macro_code;
+	min_code = config->infin_code;
+
+	if (code > max_code)
+		code = max_code;
+	if (code < min_code)
+		code = min_code;
+
+	cmdh = MOTOR_DAC_CTRL_MODE_1 | (code >> 8); /* PS EN x x M W TD9 TD8*/
+	cmdl = code; /* TD7 ~ TD0 */
+	cmd |= (cmdh << 16) | (cmdl << 8);
+
+	dprintk(1, "cmdh: %x, cmdl: %x, cmd: %x", cmdh, cmdl, cmd);
+	dprintk(1, "DAC code: %x", code);
+
+	motor_write(c, cmd);
+	finished = 0;
+	while ((!finished) && timeout--) {
+		msleep(1);
+		motor_read(c, &val);
+		cmdh = val >> 16;
+		cmdl = val >> 8;
+
+		dprintk(1, "cmdh & MOTOR_F = %x", cmdh & MOTOR_F);
+		finished = cmdh & MOTOR_F;
+		finished = (finished) ? 0 : 1;
+	};
+
+	if (finished) {
+		dprintk(1, "Moving from code %x to code %x takes %d ms.",
+		       config->cur_code, code, 25-timeout);
+		return 0;
+	} else {
+		eprintk("Unable to move motor to step %d, TIMEOUT!!", step);
+		return -1;
+	}
+
+}
+
+int s5k4e1_motor_wakeup(struct i2c_client *client)
+{
+	/* hardware wakeup: set PS = 1 */
+	return motor_write(client, 0xC00000);
+}
+
+int s5k4e1_motor_standby(struct i2c_client *client)
+{
+	/* hardware standby: set PS = 0 */
+	return motor_write(client, 0x400000);
+}
+
+int s5k4e1_motor_init(struct i2c_client *client, struct s5k4e1_motor *config)
+{
+
+	int ret;
+	int infin_cur, macro_cur;
+	int step_res, step_time;
+	int val;
+
+	DBG_entering;
+	infin_cur = MAX(MOTOR_INFIN_CUR, MOTOR_DAC_MIN_CUR);
+	macro_cur = MIN(MOTOR_MACRO_CUR, MOTOR_DAC_MAX_CUR);
+	step_res = 1 << MOTOR_STEP_SHIFT;
+	step_time = MOTOR_STEP_TIME;
+
+	/*config->motor = client;*/
+	config->infin_cur = infin_cur;
+	config->macro_cur = macro_cur;
+
+	config->infin_code = MOTOR_INFIN_CODE;
+	config->macro_code = MOTOR_MACRO_CODE;
+
+	config->max_step = ((config->macro_code - config->infin_code)
+			    >> MOTOR_STEP_SHIFT) + 1;
+	config->step_res = step_res;
+	config->step_time = step_time;
+
+	dprintk(1, "max_step: %d, step_res: %d, step_time: %d",
+		config->max_step, step_res, step_time);
+
+	/* Set motor step time and resolution */
+	val = (MOTOR_DAC_CTRL_MODE_0 << 16) | (step_res << 8) | step_time;
+	ret = motor_write(client, val);
+
+	/* Note here, maybe macro_code */
+	ret |= s5k4e1_motor_goto_position(client, config->infin_code,
+					  config, 0);
+	if (!ret) {
+		config->cur_code = config->infin_code;
+		dprintk(1, "Motor initialization success!");
+	} else
+		eprintk("Error while initializing motor!!!");
+
+	return ret;
+}
+
+int s5k4e1_motor_set_focus(struct i2c_client *c,
+			   unsigned int step,
+			   struct s5k4e1_motor *config)
+{
+	int s_code, ret;
+	int max_step = config->max_step;
+	unsigned int val = step;
+
+	if (val > max_step)
+		val = max_step;
+
+	s_code = (val << MOTOR_STEP_SHIFT);
+	s_code += config->infin_code;
+
+	ret = s5k4e1_motor_goto_position(c, s_code, config, step);
+	if (!ret)
+		config->cur_code = s_code;
+
+	return ret;
+}
+
+static int s5k4e1_motor_g_ctrl(struct v4l2_subdev *sd,
+			       struct v4l2_control *ctrl)
+{
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	struct s5k4e1_motor *config = to_motor_config(sd);
+	int ret;
+
+	DBG_entering;
+	ret = s5k4e1_motor_get_focus(c, &ctrl->value, config);
+	if (ret) {
+		eprintk("error call s5k4e1_motor_get_focue");
+		return ret;
+	}
+	DBG_leaving;
+	return 0;
+}
+
+static int s5k4e1_motor_s_ctrl(struct v4l2_subdev *sd,
+			       struct v4l2_control *ctrl)
+{
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	struct s5k4e1_motor *config = to_motor_config(sd);
+	int ret;
+
+	DBG_entering;
+	ret = s5k4e1_motor_set_focus(c, ctrl->value, config);
+	if (ret) {
+		eprintk("error call s5k4e1_motor_set_focue");
+		return ret;
+	}
+	DBG_leaving;
+	return 0;
+}
+
+int s5k4e1_motor_get_focus(struct i2c_client *c,
+			   unsigned int *step,
+			   struct s5k4e1_motor *config)
+{
+	int ret_step;
+
+	ret_step = ((config->cur_code - config->infin_code)
+		    >> MOTOR_STEP_SHIFT);
+
+	if (ret_step <= config->max_step)
+		*step = ret_step;
+	else
+		*step = config->max_step;
+
+	return 0;
+}
+
+int s5k4e1_motor_max_step(struct i2c_client *c,
+			  unsigned int *max_code,
+			  struct s5k4e1_motor *config)
+{
+	if (config->max_step != 0)
+		*max_code = config->max_step;
+	return 0;
+
+}
+
+static int s5k4e1_motor_queryctrl(struct v4l2_subdev *sd,
+			    struct v4l2_queryctrl *qc)
+{
+	struct s5k4e1_motor *config = to_motor_config(sd);
+
+	DBG_entering;
+	dprintk(1, "got focus range of %d", config->max_step);
+	if (config->max_step != 0)
+		qc->maximum = config->max_step;
+	DBG_leaving;
+	return 0;
+}
+
+static const struct v4l2_subdev_core_ops s5k4e1_motor_core_ops = {
+	.g_ctrl = s5k4e1_motor_g_ctrl,
+	.s_ctrl = s5k4e1_motor_s_ctrl,
+	.queryctrl = s5k4e1_motor_queryctrl,
+};
+
+static const struct v4l2_subdev_ops s5k4e1_motor_ops = {
+	.core = &s5k4e1_motor_core_ops,
+};
+
+static int s5k4e1_motor_detect(struct i2c_client *client)
+{
+	struct i2c_adapter *adapter = client->adapter;
+	int adap_id = i2c_adapter_id(adapter);
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
+		eprintk("error i2c check func");
+		return -ENODEV;
+	}
+
+	if (adap_id != 1) {
+		eprintk("adap_id != 1");
+		return -ENODEV;
+	}
+
+	if (s5k4e1_motor_wakeup(client))
+		eprintk("unable to wakeup s5k4e1 motor.");
+
+	return 0;
+}
+
+static int s5k4e1_motor_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	struct s5k4e1_motor *info;
+	struct v4l2_subdev *sd;
+	int ret = -1;
+/* 	struct i2c_client *motor; */
+
+	DBG_entering;
+	v4l_info(client, "chip found @ 0x%x (%s)\n",
+		 client->addr << 1, client->adapter->name);
+	/*
+	 * Setup sensor configuration structure
+	 */
+	info = kzalloc(sizeof(struct s5k4e1_motor), GFP_KERNEL);
+	if (!info) {
+		eprintk("fail to malloc for ci_motor");
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = s5k4e1_motor_detect(client);
+	if (ret) {
+		eprintk("error s5k4e1_motor_detect");
+		goto out_free;
+	}
+
+	sd = &info->sd;
+	v4l2_i2c_subdev_init(sd, client, &s5k4e1_motor_ops);
+
+	/*
+	 * Initialization S5K4E1
+	 * then turn into standby mode
+	 */
+	ret = s5k4e1_motor_init(client, info);
+	if (ret) {
+		eprintk("error calling s5k4e1_motor_init");
+		goto out_free;
+	}
+
+	ret = 0;
+	goto out;
+
+out_free:
+	kfree(info);
+	DBG_leaving;
+out:
+	return ret;
+}
+
+/*
+ * XXX: Need to be checked
+ */
+static int s5k4e1_motor_remove(struct i2c_client *client)
+{
+	struct v4l2_subdev *sd = i2c_get_clientdata(client);
+
+	DBG_entering;
+
+	v4l2_device_unregister_subdev(sd);
+	kfree(to_motor_config(sd));
+
+	DBG_leaving;
+	return 0;
+}
+
+static const struct i2c_device_id s5k4e1_motor_id[] = {
+	{"s5k4e1_motor", 0},
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, s5k4e1_motor_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
+	.name = "s5k4e1_motor",
+	.probe = s5k4e1_motor_probe,
+	.remove = s5k4e1_motor_remove,
+	/* .suspend = ov5630_suspend,
+	 * .resume = ov5630_resume, */
+	.id_table = s5k4e1_motor_id,
+};
+MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
+MODULE_DESCRIPTION("A low-level driver for Samsung S5K4E1 sensor motor");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.h b/drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.h
new file mode 100644
index 0000000..04f9436
--- /dev/null
+++ b/drivers/media/video/mrstci/mrsts5k4e1_motor/mrsts5k4e1_motor.h
@@ -0,0 +1,102 @@
+/*
+ * Support for Moorestown Langwell Camera Imaging ISP subsystem.
+ *
+ * Copyright (c) 2009 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.
+ *
+ *
+ * Xiaolin Zhang <xiaolin.zhang@intel.com>
+ */
+
+#include <media/v4l2-subdev.h>
+
+/* DAC output max current (mA) */
+#define MOTOR_DAC_MAX_CUR	125
+/* DAC output min current (mA) */
+#define MOTOR_DAC_MIN_CUR	1
+/* DAC max code (Hex) */
+#define MOTOR_DAC_CODE_MAX 	0x3FF
+/* DAC min code (Hex) */
+#define MOTOR_DAC_CODE_MIN	0x0
+
+/* VCM start code (Hex) */
+#define MOTOR_INFIN_CODE	0x120
+/* VCM stop code (Hex) */
+#define MOTOR_MACRO_CODE	0x205
+
+#define MOTOR_STEP_SHIFT	4	/* Step res = 2^4 = 10H */
+#define MOTOR_STEP_TIME		20	/* Step time = 50us x 20d = 1ms */
+
+/* VCM start current (mA) */
+#define MOTOR_INFIN_CUR		((MOTOR_DAC_MAX_CUR / MOTOR_DAC_CODE_MAX) \
+				 * MOTOR_INFIN_CODE + 1)
+/* VCM max current for Macro (mA) */
+#define MOTOR_MACRO_CUR		((MOTOR_DAC_MAX_CUR / MOTOR_DAC_CODE_MAX) \
+				 * MOTOR_MACRO_CODE + 1)
+
+
+#define MOTOR_DAC_BIT_RES	10
+#define MOTOR_DAC_MAX_CODE	((1 << MOTOR_DAC_BIT_RES) - 1)
+
+#define MOTOR_STEP_SHIFT	4
+
+#define MAX(x, y)	((x) > (y) ? (x) : (y))
+#define MIN(x, y)	((x) < (y) ? (x) : (y))
+
+/* DAC register related define */
+#define MOTOR_PS	(1 << 7) /* power save */
+#define MOTOR_EN	(1 << 6) /* out pin status*/
+#define MOTOR_M		(1 << 3) /* mode select */
+#define MOTOR_W		(1 << 2) /* register address */
+#define MOTOR_F		(1 << 4) /* finish flag */
+
+#define MOTOR_DAC_CODE_L(x)	(x & 0xff)
+#define MOTOR_DAC_CODE_H(x)	((x >> 8) & 0xf3)
+
+/* Step mode setting */
+#define MOTOR_DAC_CTRL_MODE_0	0xCC
+/* DAC code setting */
+#define MOTOR_DAC_CTRL_MODE_1	0xC8
+
+#define S5K4E1_MOTOR_ADDR	(0x18 >> 1)
+/*#define POWER_EN_PIN	7*/
+#define GPIO_AF_PD	95
+
+#define DEBUG	0
+
+struct s5k4e1_motor{
+	/*struct i2c_client *motor;*/
+	unsigned int infin_cur;
+	unsigned int infin_code;
+	unsigned int macro_cur;
+	unsigned int macro_code;
+	unsigned int max_step;
+	unsigned int cur_code;
+	unsigned int step_res;
+	unsigned int step_time;
+	struct v4l2_subdev sd;
+};
+
+extern int s5k4e1_motor_init(struct i2c_client *client,
+			     struct s5k4e1_motor *config);
+extern int s5k4e1_motor_standby(struct i2c_client *client);
+extern int s5k4e1_motor_wakeup(struct i2c_client *client);
+extern int s5k4e1_motor_set_focus(struct i2c_client *c, unsigned int step,
+				  struct s5k4e1_motor *config);
+extern int s5k4e1_motor_get_focus(struct i2c_client *c, unsigned int *step,
+				  struct s5k4e1_motor *config);
+extern int s5k4e1_motor_max_step(struct i2c_client *c, unsigned int *max_code,
+				 struct s5k4e1_motor *config);
-- 
1.6.0.6