0001
0002
0003
0004
0005
0006
0007 #include <linux/kernel.h>
0008 #include <linux/of_platform.h>
0009
0010 #include <media/i2c/tvp514x.h>
0011 #include <media/i2c/adv7343.h>
0012
0013 #include "common.h"
0014 #include "da8xx.h"
0015
0016 struct pdata_init {
0017 const char *compatible;
0018 void (*fn)(void);
0019 };
0020
0021 #define TVP5147_CH0 "tvp514x-0"
0022 #define TVP5147_CH1 "tvp514x-1"
0023
0024
0025 static struct tvp514x_platform_data tvp5146_pdata = {
0026 .clk_polarity = 0,
0027 .hs_polarity = 1,
0028 .vs_polarity = 1,
0029 };
0030
0031 #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
0032
0033 static struct vpif_input da850_ch0_inputs[] = {
0034 {
0035 .input = {
0036 .index = 0,
0037 .name = "Composite",
0038 .type = V4L2_INPUT_TYPE_CAMERA,
0039 .capabilities = V4L2_IN_CAP_STD,
0040 .std = TVP514X_STD_ALL,
0041 },
0042 .input_route = INPUT_CVBS_VI2B,
0043 .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
0044 .subdev_name = TVP5147_CH0,
0045 },
0046 };
0047
0048 static struct vpif_input da850_ch1_inputs[] = {
0049 {
0050 .input = {
0051 .index = 0,
0052 .name = "S-Video",
0053 .type = V4L2_INPUT_TYPE_CAMERA,
0054 .capabilities = V4L2_IN_CAP_STD,
0055 .std = TVP514X_STD_ALL,
0056 },
0057 .input_route = INPUT_SVIDEO_VI2C_VI1C,
0058 .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
0059 .subdev_name = TVP5147_CH1,
0060 },
0061 };
0062
0063 static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
0064 {
0065 .name = TVP5147_CH0,
0066 .board_info = {
0067 I2C_BOARD_INFO("tvp5146", 0x5d),
0068 .platform_data = &tvp5146_pdata,
0069 },
0070 },
0071 {
0072 .name = TVP5147_CH1,
0073 .board_info = {
0074 I2C_BOARD_INFO("tvp5146", 0x5c),
0075 .platform_data = &tvp5146_pdata,
0076 },
0077 },
0078 };
0079
0080 static struct vpif_capture_config da850_vpif_capture_config = {
0081 .subdev_info = da850_vpif_capture_sdev_info,
0082 .subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
0083 .chan_config[0] = {
0084 .inputs = da850_ch0_inputs,
0085 .input_count = ARRAY_SIZE(da850_ch0_inputs),
0086 .vpif_if = {
0087 .if_type = VPIF_IF_BT656,
0088 .hd_pol = 1,
0089 .vd_pol = 1,
0090 .fid_pol = 0,
0091 },
0092 },
0093 .chan_config[1] = {
0094 .inputs = da850_ch1_inputs,
0095 .input_count = ARRAY_SIZE(da850_ch1_inputs),
0096 .vpif_if = {
0097 .if_type = VPIF_IF_BT656,
0098 .hd_pol = 1,
0099 .vd_pol = 1,
0100 .fid_pol = 0,
0101 },
0102 },
0103 .card_name = "DA850/OMAP-L138 Video Capture",
0104 };
0105
0106 static void __init da850_vpif_legacy_register_capture(void)
0107 {
0108 int ret;
0109
0110 ret = da850_register_vpif_capture(&da850_vpif_capture_config);
0111 if (ret)
0112 pr_warn("%s: VPIF capture setup failed: %d\n",
0113 __func__, ret);
0114 }
0115
0116 static void __init da850_vpif_capture_legacy_init_lcdk(void)
0117 {
0118 da850_vpif_capture_config.subdev_count = 1;
0119 da850_vpif_legacy_register_capture();
0120 }
0121
0122 static void __init da850_vpif_capture_legacy_init_evm(void)
0123 {
0124 da850_vpif_legacy_register_capture();
0125 }
0126
0127 static struct adv7343_platform_data adv7343_pdata = {
0128 .mode_config = {
0129 .dac = { 1, 1, 1 },
0130 },
0131 .sd_config = {
0132 .sd_dac_out = { 1 },
0133 },
0134 };
0135
0136 static struct vpif_subdev_info da850_vpif_subdev[] = {
0137 {
0138 .name = "adv7343",
0139 .board_info = {
0140 I2C_BOARD_INFO("adv7343", 0x2a),
0141 .platform_data = &adv7343_pdata,
0142 },
0143 },
0144 };
0145
0146 static const struct vpif_output da850_ch0_outputs[] = {
0147 {
0148 .output = {
0149 .index = 0,
0150 .name = "Composite",
0151 .type = V4L2_OUTPUT_TYPE_ANALOG,
0152 .capabilities = V4L2_OUT_CAP_STD,
0153 .std = V4L2_STD_ALL,
0154 },
0155 .subdev_name = "adv7343",
0156 .output_route = ADV7343_COMPOSITE_ID,
0157 },
0158 {
0159 .output = {
0160 .index = 1,
0161 .name = "S-Video",
0162 .type = V4L2_OUTPUT_TYPE_ANALOG,
0163 .capabilities = V4L2_OUT_CAP_STD,
0164 .std = V4L2_STD_ALL,
0165 },
0166 .subdev_name = "adv7343",
0167 .output_route = ADV7343_SVIDEO_ID,
0168 },
0169 };
0170
0171 static struct vpif_display_config da850_vpif_display_config = {
0172 .subdevinfo = da850_vpif_subdev,
0173 .subdev_count = ARRAY_SIZE(da850_vpif_subdev),
0174 .chan_config[0] = {
0175 .outputs = da850_ch0_outputs,
0176 .output_count = ARRAY_SIZE(da850_ch0_outputs),
0177 },
0178 .card_name = "DA850/OMAP-L138 Video Display",
0179 };
0180
0181 static void __init da850_vpif_display_legacy_init_evm(void)
0182 {
0183 int ret;
0184
0185 ret = da850_register_vpif_display(&da850_vpif_display_config);
0186 if (ret)
0187 pr_warn("%s: VPIF display setup failed: %d\n",
0188 __func__, ret);
0189 }
0190
0191 static void pdata_quirks_check(struct pdata_init *quirks)
0192 {
0193 while (quirks->compatible) {
0194 if (of_machine_is_compatible(quirks->compatible)) {
0195 if (quirks->fn)
0196 quirks->fn();
0197 }
0198 quirks++;
0199 }
0200 }
0201
0202 static struct pdata_init pdata_quirks[] __initdata = {
0203 { "ti,da850-lcdk", da850_vpif_capture_legacy_init_lcdk, },
0204 { "ti,da850-evm", da850_vpif_display_legacy_init_evm, },
0205 { "ti,da850-evm", da850_vpif_capture_legacy_init_evm, },
0206 { },
0207 };
0208
0209 void __init pdata_quirks_init(void)
0210 {
0211 pdata_quirks_check(pdata_quirks);
0212 }