pdata-quirks.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * Legacy platform_data quirks
  3. *
  4. * Copyright (C) 2016 BayLibre, Inc
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/of_platform.h>
  12. #include <media/i2c/tvp514x.h>
  13. #include <media/i2c/adv7343.h>
  14. #include <mach/common.h>
  15. #include <mach/da8xx.h>
  16. struct pdata_init {
  17. const char *compatible;
  18. void (*fn)(void);
  19. };
  20. #define TVP5147_CH0 "tvp514x-0"
  21. #define TVP5147_CH1 "tvp514x-1"
  22. /* VPIF capture configuration */
  23. static struct tvp514x_platform_data tvp5146_pdata = {
  24. .clk_polarity = 0,
  25. .hs_polarity = 1,
  26. .vs_polarity = 1,
  27. };
  28. #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  29. static struct vpif_input da850_ch0_inputs[] = {
  30. {
  31. .input = {
  32. .index = 0,
  33. .name = "Composite",
  34. .type = V4L2_INPUT_TYPE_CAMERA,
  35. .capabilities = V4L2_IN_CAP_STD,
  36. .std = TVP514X_STD_ALL,
  37. },
  38. .input_route = INPUT_CVBS_VI2B,
  39. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  40. .subdev_name = TVP5147_CH0,
  41. },
  42. };
  43. static struct vpif_input da850_ch1_inputs[] = {
  44. {
  45. .input = {
  46. .index = 0,
  47. .name = "S-Video",
  48. .type = V4L2_INPUT_TYPE_CAMERA,
  49. .capabilities = V4L2_IN_CAP_STD,
  50. .std = TVP514X_STD_ALL,
  51. },
  52. .input_route = INPUT_SVIDEO_VI2C_VI1C,
  53. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  54. .subdev_name = TVP5147_CH1,
  55. },
  56. };
  57. static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
  58. {
  59. .name = TVP5147_CH0,
  60. .board_info = {
  61. I2C_BOARD_INFO("tvp5146", 0x5d),
  62. .platform_data = &tvp5146_pdata,
  63. },
  64. },
  65. {
  66. .name = TVP5147_CH1,
  67. .board_info = {
  68. I2C_BOARD_INFO("tvp5146", 0x5c),
  69. .platform_data = &tvp5146_pdata,
  70. },
  71. },
  72. };
  73. static struct vpif_capture_config da850_vpif_capture_config = {
  74. .subdev_info = da850_vpif_capture_sdev_info,
  75. .subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
  76. .chan_config[0] = {
  77. .inputs = da850_ch0_inputs,
  78. .input_count = ARRAY_SIZE(da850_ch0_inputs),
  79. .vpif_if = {
  80. .if_type = VPIF_IF_BT656,
  81. .hd_pol = 1,
  82. .vd_pol = 1,
  83. .fid_pol = 0,
  84. },
  85. },
  86. .chan_config[1] = {
  87. .inputs = da850_ch1_inputs,
  88. .input_count = ARRAY_SIZE(da850_ch1_inputs),
  89. .vpif_if = {
  90. .if_type = VPIF_IF_BT656,
  91. .hd_pol = 1,
  92. .vd_pol = 1,
  93. .fid_pol = 0,
  94. },
  95. },
  96. .card_name = "DA850/OMAP-L138 Video Capture",
  97. };
  98. static void __init da850_vpif_legacy_register_capture(void)
  99. {
  100. int ret;
  101. ret = da850_register_vpif_capture(&da850_vpif_capture_config);
  102. if (ret)
  103. pr_warn("%s: VPIF capture setup failed: %d\n",
  104. __func__, ret);
  105. }
  106. static void __init da850_vpif_capture_legacy_init_lcdk(void)
  107. {
  108. da850_vpif_capture_config.subdev_count = 1;
  109. da850_vpif_legacy_register_capture();
  110. }
  111. static void __init da850_vpif_capture_legacy_init_evm(void)
  112. {
  113. da850_vpif_legacy_register_capture();
  114. }
  115. static struct adv7343_platform_data adv7343_pdata = {
  116. .mode_config = {
  117. .dac = { 1, 1, 1 },
  118. },
  119. .sd_config = {
  120. .sd_dac_out = { 1 },
  121. },
  122. };
  123. static struct vpif_subdev_info da850_vpif_subdev[] = {
  124. {
  125. .name = "adv7343",
  126. .board_info = {
  127. I2C_BOARD_INFO("adv7343", 0x2a),
  128. .platform_data = &adv7343_pdata,
  129. },
  130. },
  131. };
  132. static const struct vpif_output da850_ch0_outputs[] = {
  133. {
  134. .output = {
  135. .index = 0,
  136. .name = "Composite",
  137. .type = V4L2_OUTPUT_TYPE_ANALOG,
  138. .capabilities = V4L2_OUT_CAP_STD,
  139. .std = V4L2_STD_ALL,
  140. },
  141. .subdev_name = "adv7343",
  142. .output_route = ADV7343_COMPOSITE_ID,
  143. },
  144. {
  145. .output = {
  146. .index = 1,
  147. .name = "S-Video",
  148. .type = V4L2_OUTPUT_TYPE_ANALOG,
  149. .capabilities = V4L2_OUT_CAP_STD,
  150. .std = V4L2_STD_ALL,
  151. },
  152. .subdev_name = "adv7343",
  153. .output_route = ADV7343_SVIDEO_ID,
  154. },
  155. };
  156. static struct vpif_display_config da850_vpif_display_config = {
  157. .subdevinfo = da850_vpif_subdev,
  158. .subdev_count = ARRAY_SIZE(da850_vpif_subdev),
  159. .chan_config[0] = {
  160. .outputs = da850_ch0_outputs,
  161. .output_count = ARRAY_SIZE(da850_ch0_outputs),
  162. },
  163. .card_name = "DA850/OMAP-L138 Video Display",
  164. };
  165. static void __init da850_vpif_display_legacy_init_evm(void)
  166. {
  167. int ret;
  168. ret = da850_register_vpif_display(&da850_vpif_display_config);
  169. if (ret)
  170. pr_warn("%s: VPIF display setup failed: %d\n",
  171. __func__, ret);
  172. }
  173. static void pdata_quirks_check(struct pdata_init *quirks)
  174. {
  175. while (quirks->compatible) {
  176. if (of_machine_is_compatible(quirks->compatible)) {
  177. if (quirks->fn)
  178. quirks->fn();
  179. }
  180. quirks++;
  181. }
  182. }
  183. static struct pdata_init pdata_quirks[] __initdata = {
  184. { "ti,da850-lcdk", da850_vpif_capture_legacy_init_lcdk, },
  185. { "ti,da850-evm", da850_vpif_display_legacy_init_evm, },
  186. { "ti,da850-evm", da850_vpif_capture_legacy_init_evm, },
  187. { /* sentinel */ },
  188. };
  189. void __init pdata_quirks_init(void)
  190. {
  191. pdata_quirks_check(pdata_quirks);
  192. }