Linux Audio

Check our new training course

Loading...
v5.4
  1// SPDX-License-Identifier: GPL-2.0+
  2/*
  3 * i.MX drm driver - parallel display implementation
  4 *
  5 * Copyright (C) 2012 Sascha Hauer, Pengutronix
  6 */
  7
  8#include <linux/component.h>
  9#include <linux/module.h>
 10#include <linux/platform_device.h>
 11#include <linux/videodev2.h>
 12
 13#include <video/of_display_timing.h>
 14
 15#include <drm/drm_atomic_helper.h>
 
 16#include <drm/drm_fb_helper.h>
 
 17#include <drm/drm_of.h>
 18#include <drm/drm_panel.h>
 19#include <drm/drm_probe_helper.h>
 
 20
 21#include "imx-drm.h"
 22
 23struct imx_parallel_display {
 24	struct drm_connector connector;
 25	struct drm_encoder encoder;
 
 
 
 
 
 26	struct device *dev;
 27	void *edid;
 28	int edid_len;
 29	u32 bus_format;
 30	u32 bus_flags;
 31	struct drm_display_mode mode;
 32	struct drm_panel *panel;
 33	struct drm_bridge *bridge;
 34};
 35
 36static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector *c)
 37{
 38	return container_of(c, struct imx_parallel_display, connector);
 39}
 40
 41static inline struct imx_parallel_display *enc_to_imxpd(struct drm_encoder *e)
 42{
 43	return container_of(e, struct imx_parallel_display, encoder);
 44}
 45
 46static int imx_pd_connector_get_modes(struct drm_connector *connector)
 47{
 48	struct imx_parallel_display *imxpd = con_to_imxpd(connector);
 49	struct device_node *np = imxpd->dev->of_node;
 50	int num_modes;
 51
 52	num_modes = drm_panel_get_modes(imxpd->panel);
 53	if (num_modes > 0)
 54		return num_modes;
 55
 56	if (imxpd->edid) {
 57		drm_connector_update_edid_property(connector, imxpd->edid);
 58		num_modes = drm_add_edid_modes(connector, imxpd->edid);
 59	}
 60
 61	if (np) {
 62		struct drm_display_mode *mode = drm_mode_create(connector->dev);
 63		int ret;
 64
 65		if (!mode)
 66			return -EINVAL;
 67
 68		ret = of_get_drm_display_mode(np, &imxpd->mode,
 69					      &imxpd->bus_flags,
 70					      OF_USE_NATIVE_MODE);
 71		if (ret)
 72			return ret;
 73
 74		drm_mode_copy(mode, &imxpd->mode);
 75		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
 76		drm_mode_probed_add(connector, mode);
 77		num_modes++;
 78	}
 79
 80	return num_modes;
 81}
 82
 83static struct drm_encoder *imx_pd_connector_best_encoder(
 84		struct drm_connector *connector)
 85{
 86	struct imx_parallel_display *imxpd = con_to_imxpd(connector);
 87
 88	return &imxpd->encoder;
 89}
 90
 91static void imx_pd_encoder_enable(struct drm_encoder *encoder)
 92{
 93	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
 94
 95	drm_panel_prepare(imxpd->panel);
 96	drm_panel_enable(imxpd->panel);
 97}
 98
 99static void imx_pd_encoder_disable(struct drm_encoder *encoder)
100{
101	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
102
103	drm_panel_disable(imxpd->panel);
104	drm_panel_unprepare(imxpd->panel);
105}
106
107static int imx_pd_encoder_atomic_check(struct drm_encoder *encoder,
108				       struct drm_crtc_state *crtc_state,
109				       struct drm_connector_state *conn_state)
 
 
 
 
 
 
 
 
 
 
 
 
110{
111	struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
112	struct drm_display_info *di = &conn_state->connector->display_info;
113	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
 
114
115	if (!imxpd->bus_format && di->num_bus_formats) {
116		imx_crtc_state->bus_flags = di->bus_flags;
117		imx_crtc_state->bus_format = di->bus_formats[0];
118	} else {
119		imx_crtc_state->bus_flags = imxpd->bus_flags;
120		imx_crtc_state->bus_format = imxpd->bus_format;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121	}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122	imx_crtc_state->di_hsync_pin = 2;
123	imx_crtc_state->di_vsync_pin = 3;
124
125	return 0;
126}
127
128static const struct drm_connector_funcs imx_pd_connector_funcs = {
129	.fill_modes = drm_helper_probe_single_connector_modes,
130	.destroy = imx_drm_connector_destroy,
131	.reset = drm_atomic_helper_connector_reset,
132	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
133	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
134};
135
136static const struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = {
137	.get_modes = imx_pd_connector_get_modes,
138	.best_encoder = imx_pd_connector_best_encoder,
139};
140
141static const struct drm_encoder_funcs imx_pd_encoder_funcs = {
142	.destroy = imx_drm_encoder_destroy,
 
 
 
 
 
 
 
143};
144
145static const struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = {
146	.enable = imx_pd_encoder_enable,
147	.disable = imx_pd_encoder_disable,
148	.atomic_check = imx_pd_encoder_atomic_check,
149};
150
151static int imx_pd_register(struct drm_device *drm,
152	struct imx_parallel_display *imxpd)
153{
154	struct drm_encoder *encoder = &imxpd->encoder;
 
 
 
 
 
155	int ret;
156
 
 
 
 
 
 
 
 
 
 
157	ret = imx_drm_encoder_parse_of(drm, encoder, imxpd->dev->of_node);
158	if (ret)
159		return ret;
160
161	/* set the connector's dpms to OFF so that
162	 * drm_helper_connector_dpms() won't return
163	 * immediately since the current state is ON
164	 * at this point.
165	 */
166	imxpd->connector.dpms = DRM_MODE_DPMS_OFF;
167
168	drm_encoder_helper_add(encoder, &imx_pd_encoder_helper_funcs);
169	drm_encoder_init(drm, encoder, &imx_pd_encoder_funcs,
170			 DRM_MODE_ENCODER_NONE, NULL);
171
172	if (!imxpd->bridge) {
173		drm_connector_helper_add(&imxpd->connector,
174				&imx_pd_connector_helper_funcs);
175		drm_connector_init(drm, &imxpd->connector,
176				   &imx_pd_connector_funcs,
177				   DRM_MODE_CONNECTOR_DPI);
178	}
179
180	if (imxpd->panel)
181		drm_panel_attach(imxpd->panel, &imxpd->connector);
182
183	if (imxpd->bridge) {
184		ret = drm_bridge_attach(encoder, imxpd->bridge, NULL);
185		if (ret < 0) {
186			dev_err(imxpd->dev, "failed to attach bridge: %d\n",
187				ret);
188			return ret;
189		}
190	} else {
191		drm_connector_attach_encoder(&imxpd->connector, encoder);
 
 
 
 
 
192	}
193
194	return 0;
195}
196
197static int imx_pd_bind(struct device *dev, struct device *master, void *data)
 
 
 
 
198{
199	struct drm_device *drm = data;
200	struct device_node *np = dev->of_node;
201	const u8 *edidp;
202	struct imx_parallel_display *imxpd;
 
203	int ret;
204	u32 bus_format = 0;
205	const char *fmt;
206
207	imxpd = devm_kzalloc(dev, sizeof(*imxpd), GFP_KERNEL);
208	if (!imxpd)
209		return -ENOMEM;
210
211	edidp = of_get_property(np, "edid", &imxpd->edid_len);
 
 
 
 
 
 
212	if (edidp)
213		imxpd->edid = kmemdup(edidp, imxpd->edid_len, GFP_KERNEL);
214
215	ret = of_property_read_string(np, "interface-pix-fmt", &fmt);
216	if (!ret) {
217		if (!strcmp(fmt, "rgb24"))
218			bus_format = MEDIA_BUS_FMT_RGB888_1X24;
219		else if (!strcmp(fmt, "rgb565"))
220			bus_format = MEDIA_BUS_FMT_RGB565_1X16;
221		else if (!strcmp(fmt, "bgr666"))
222			bus_format = MEDIA_BUS_FMT_RGB666_1X18;
223		else if (!strcmp(fmt, "lvds666"))
224			bus_format = MEDIA_BUS_FMT_RGB666_1X24_CPADHI;
225	}
226	imxpd->bus_format = bus_format;
227
228	/* port@1 is the output port */
229	ret = drm_of_find_panel_or_bridge(np, 1, 0, &imxpd->panel, &imxpd->bridge);
230	if (ret && ret != -ENODEV)
231		return ret;
232
233	imxpd->dev = dev;
234
235	ret = imx_pd_register(drm, imxpd);
236	if (ret)
237		return ret;
238
239	dev_set_drvdata(dev, imxpd);
240
241	return 0;
242}
243
244static void imx_pd_unbind(struct device *dev, struct device *master,
245	void *data)
246{
247	struct imx_parallel_display *imxpd = dev_get_drvdata(dev);
248
249	if (imxpd->panel)
250		drm_panel_detach(imxpd->panel);
251
252	kfree(imxpd->edid);
253}
254
255static const struct component_ops imx_pd_ops = {
256	.bind	= imx_pd_bind,
257	.unbind	= imx_pd_unbind,
258};
259
260static int imx_pd_probe(struct platform_device *pdev)
261{
262	return component_add(&pdev->dev, &imx_pd_ops);
263}
264
265static int imx_pd_remove(struct platform_device *pdev)
266{
267	component_del(&pdev->dev, &imx_pd_ops);
268
269	return 0;
270}
271
272static const struct of_device_id imx_pd_dt_ids[] = {
273	{ .compatible = "fsl,imx-parallel-display", },
274	{ /* sentinel */ }
275};
276MODULE_DEVICE_TABLE(of, imx_pd_dt_ids);
277
278static struct platform_driver imx_pd_driver = {
279	.probe		= imx_pd_probe,
280	.remove		= imx_pd_remove,
281	.driver		= {
282		.of_match_table = imx_pd_dt_ids,
283		.name	= "imx-parallel-display",
284	},
285};
286
287module_platform_driver(imx_pd_driver);
288
289MODULE_DESCRIPTION("i.MX parallel display driver");
290MODULE_AUTHOR("Sascha Hauer, Pengutronix");
291MODULE_LICENSE("GPL");
292MODULE_ALIAS("platform:imx-parallel-display");
v5.14.15
  1// SPDX-License-Identifier: GPL-2.0+
  2/*
  3 * i.MX drm driver - parallel display implementation
  4 *
  5 * Copyright (C) 2012 Sascha Hauer, Pengutronix
  6 */
  7
  8#include <linux/component.h>
  9#include <linux/module.h>
 10#include <linux/platform_device.h>
 11#include <linux/videodev2.h>
 12
 13#include <video/of_display_timing.h>
 14
 15#include <drm/drm_atomic_helper.h>
 16#include <drm/drm_bridge.h>
 17#include <drm/drm_fb_helper.h>
 18#include <drm/drm_managed.h>
 19#include <drm/drm_of.h>
 20#include <drm/drm_panel.h>
 21#include <drm/drm_probe_helper.h>
 22#include <drm/drm_simple_kms_helper.h>
 23
 24#include "imx-drm.h"
 25
 26struct imx_parallel_display_encoder {
 27	struct drm_connector connector;
 28	struct drm_encoder encoder;
 29	struct drm_bridge bridge;
 30	struct imx_parallel_display *pd;
 31};
 32
 33struct imx_parallel_display {
 34	struct device *dev;
 35	void *edid;
 
 36	u32 bus_format;
 37	u32 bus_flags;
 38	struct drm_display_mode mode;
 39	struct drm_panel *panel;
 40	struct drm_bridge *next_bridge;
 41};
 42
 43static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector *c)
 44{
 45	return container_of(c, struct imx_parallel_display_encoder, connector)->pd;
 46}
 47
 48static inline struct imx_parallel_display *bridge_to_imxpd(struct drm_bridge *b)
 49{
 50	return container_of(b, struct imx_parallel_display_encoder, bridge)->pd;
 51}
 52
 53static int imx_pd_connector_get_modes(struct drm_connector *connector)
 54{
 55	struct imx_parallel_display *imxpd = con_to_imxpd(connector);
 56	struct device_node *np = imxpd->dev->of_node;
 57	int num_modes;
 58
 59	num_modes = drm_panel_get_modes(imxpd->panel, connector);
 60	if (num_modes > 0)
 61		return num_modes;
 62
 63	if (imxpd->edid) {
 64		drm_connector_update_edid_property(connector, imxpd->edid);
 65		num_modes = drm_add_edid_modes(connector, imxpd->edid);
 66	}
 67
 68	if (np) {
 69		struct drm_display_mode *mode = drm_mode_create(connector->dev);
 70		int ret;
 71
 72		if (!mode)
 73			return -EINVAL;
 74
 75		ret = of_get_drm_display_mode(np, &imxpd->mode,
 76					      &imxpd->bus_flags,
 77					      OF_USE_NATIVE_MODE);
 78		if (ret)
 79			return ret;
 80
 81		drm_mode_copy(mode, &imxpd->mode);
 82		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 83		drm_mode_probed_add(connector, mode);
 84		num_modes++;
 85	}
 86
 87	return num_modes;
 88}
 89
 90static void imx_pd_bridge_enable(struct drm_bridge *bridge)
 
 
 
 
 
 
 
 
 91{
 92	struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
 93
 94	drm_panel_prepare(imxpd->panel);
 95	drm_panel_enable(imxpd->panel);
 96}
 97
 98static void imx_pd_bridge_disable(struct drm_bridge *bridge)
 99{
100	struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
101
102	drm_panel_disable(imxpd->panel);
103	drm_panel_unprepare(imxpd->panel);
104}
105
106static const u32 imx_pd_bus_fmts[] = {
107	MEDIA_BUS_FMT_RGB888_1X24,
108	MEDIA_BUS_FMT_BGR888_1X24,
109	MEDIA_BUS_FMT_GBR888_1X24,
110	MEDIA_BUS_FMT_RGB666_1X18,
111	MEDIA_BUS_FMT_RGB666_1X24_CPADHI,
112	MEDIA_BUS_FMT_RGB565_1X16,
113};
114
115static u32 *
116imx_pd_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
117					 struct drm_bridge_state *bridge_state,
118					 struct drm_crtc_state *crtc_state,
119					 struct drm_connector_state *conn_state,
120					 unsigned int *num_output_fmts)
121{
 
122	struct drm_display_info *di = &conn_state->connector->display_info;
123	struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
124	u32 *output_fmts;
125
126	if (!imxpd->bus_format && !di->num_bus_formats) {
127		*num_output_fmts = ARRAY_SIZE(imx_pd_bus_fmts);
128		return kmemdup(imx_pd_bus_fmts, sizeof(imx_pd_bus_fmts),
129			       GFP_KERNEL);
130	}
131
132	*num_output_fmts = 1;
133	output_fmts = kmalloc(sizeof(*output_fmts), GFP_KERNEL);
134	if (!output_fmts)
135		return NULL;
136
137	if (!imxpd->bus_format && di->num_bus_formats)
138		output_fmts[0] = di->bus_formats[0];
139	else
140		output_fmts[0] = imxpd->bus_format;
141
142	return output_fmts;
143}
144
145static bool imx_pd_format_supported(u32 output_fmt)
146{
147	unsigned int i;
148
149	for (i = 0; i < ARRAY_SIZE(imx_pd_bus_fmts); i++) {
150		if (imx_pd_bus_fmts[i] == output_fmt)
151			return true;
152	}
153
154	return false;
155}
156
157static u32 *
158imx_pd_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
159					struct drm_bridge_state *bridge_state,
160					struct drm_crtc_state *crtc_state,
161					struct drm_connector_state *conn_state,
162					u32 output_fmt,
163					unsigned int *num_input_fmts)
164{
165	struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
166	u32 *input_fmts;
167
168	/*
169	 * If the next bridge does not support bus format negotiation, let's
170	 * use the static bus format definition (imxpd->bus_format) if it's
171	 * specified, RGB888 when it's not.
172	 */
173	if (output_fmt == MEDIA_BUS_FMT_FIXED)
174		output_fmt = imxpd->bus_format ? : MEDIA_BUS_FMT_RGB888_1X24;
175
176	/* Now make sure the requested output format is supported. */
177	if ((imxpd->bus_format && imxpd->bus_format != output_fmt) ||
178	    !imx_pd_format_supported(output_fmt)) {
179		*num_input_fmts = 0;
180		return NULL;
181	}
182
183	*num_input_fmts = 1;
184	input_fmts = kmalloc(sizeof(*input_fmts), GFP_KERNEL);
185	if (!input_fmts)
186		return NULL;
187
188	input_fmts[0] = output_fmt;
189	return input_fmts;
190}
191
192static int imx_pd_bridge_atomic_check(struct drm_bridge *bridge,
193				      struct drm_bridge_state *bridge_state,
194				      struct drm_crtc_state *crtc_state,
195				      struct drm_connector_state *conn_state)
196{
197	struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
198	struct drm_display_info *di = &conn_state->connector->display_info;
199	struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
200	struct drm_bridge_state *next_bridge_state = NULL;
201	struct drm_bridge *next_bridge;
202	u32 bus_flags, bus_fmt;
203
204	next_bridge = drm_bridge_get_next_bridge(bridge);
205	if (next_bridge)
206		next_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
207								    next_bridge);
208
209	if (next_bridge_state)
210		bus_flags = next_bridge_state->input_bus_cfg.flags;
211	else if (di->num_bus_formats)
212		bus_flags = di->bus_flags;
213	else
214		bus_flags = imxpd->bus_flags;
215
216	bus_fmt = bridge_state->input_bus_cfg.format;
217	if (!imx_pd_format_supported(bus_fmt))
218		return -EINVAL;
219
220	if (bus_flags &
221	    ~(DRM_BUS_FLAG_DE_LOW | DRM_BUS_FLAG_DE_HIGH |
222	      DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE |
223	      DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)) {
224		dev_warn(imxpd->dev, "invalid bus_flags (%x)\n", bus_flags);
225		return -EINVAL;
226	}
227
228	bridge_state->output_bus_cfg.flags = bus_flags;
229	bridge_state->input_bus_cfg.flags = bus_flags;
230	imx_crtc_state->bus_flags = bus_flags;
231	imx_crtc_state->bus_format = bridge_state->input_bus_cfg.format;
232	imx_crtc_state->di_hsync_pin = 2;
233	imx_crtc_state->di_vsync_pin = 3;
234
235	return 0;
236}
237
238static const struct drm_connector_funcs imx_pd_connector_funcs = {
239	.fill_modes = drm_helper_probe_single_connector_modes,
240	.destroy = imx_drm_connector_destroy,
241	.reset = drm_atomic_helper_connector_reset,
242	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
243	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
244};
245
246static const struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = {
247	.get_modes = imx_pd_connector_get_modes,
 
248};
249
250static const struct drm_bridge_funcs imx_pd_bridge_funcs = {
251	.enable = imx_pd_bridge_enable,
252	.disable = imx_pd_bridge_disable,
253	.atomic_reset = drm_atomic_helper_bridge_reset,
254	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
255	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
256	.atomic_check = imx_pd_bridge_atomic_check,
257	.atomic_get_input_bus_fmts = imx_pd_bridge_atomic_get_input_bus_fmts,
258	.atomic_get_output_bus_fmts = imx_pd_bridge_atomic_get_output_bus_fmts,
259};
260
261static int imx_pd_bind(struct device *dev, struct device *master, void *data)
 
 
 
 
 
 
 
262{
263	struct drm_device *drm = data;
264	struct imx_parallel_display *imxpd = dev_get_drvdata(dev);
265	struct imx_parallel_display_encoder *imxpd_encoder;
266	struct drm_connector *connector;
267	struct drm_encoder *encoder;
268	struct drm_bridge *bridge;
269	int ret;
270
271	imxpd_encoder = drmm_simple_encoder_alloc(drm, struct imx_parallel_display_encoder,
272						  encoder, DRM_MODE_ENCODER_NONE);
273	if (IS_ERR(imxpd_encoder))
274		return PTR_ERR(imxpd_encoder);
275
276	imxpd_encoder->pd = imxpd;
277	connector = &imxpd_encoder->connector;
278	encoder = &imxpd_encoder->encoder;
279	bridge = &imxpd_encoder->bridge;
280
281	ret = imx_drm_encoder_parse_of(drm, encoder, imxpd->dev->of_node);
282	if (ret)
283		return ret;
284
285	/* set the connector's dpms to OFF so that
286	 * drm_helper_connector_dpms() won't return
287	 * immediately since the current state is ON
288	 * at this point.
289	 */
290	connector->dpms = DRM_MODE_DPMS_OFF;
 
 
 
 
 
 
 
 
 
 
 
 
291
292	bridge->funcs = &imx_pd_bridge_funcs;
293	drm_bridge_attach(encoder, bridge, NULL, 0);
294
295	if (imxpd->next_bridge) {
296		ret = drm_bridge_attach(encoder, imxpd->next_bridge, bridge, 0);
297		if (ret < 0) {
298			dev_err(imxpd->dev, "failed to attach bridge: %d\n",
299				ret);
300			return ret;
301		}
302	} else {
303		drm_connector_helper_add(connector,
304					 &imx_pd_connector_helper_funcs);
305		drm_connector_init(drm, connector, &imx_pd_connector_funcs,
306				   DRM_MODE_CONNECTOR_DPI);
307
308		drm_connector_attach_encoder(connector, encoder);
309	}
310
311	return 0;
312}
313
314static const struct component_ops imx_pd_ops = {
315	.bind	= imx_pd_bind,
316};
317
318static int imx_pd_probe(struct platform_device *pdev)
319{
320	struct device *dev = &pdev->dev;
321	struct device_node *np = dev->of_node;
322	const u8 *edidp;
323	struct imx_parallel_display *imxpd;
324	int edid_len;
325	int ret;
326	u32 bus_format = 0;
327	const char *fmt;
328
329	imxpd = devm_kzalloc(dev, sizeof(*imxpd), GFP_KERNEL);
330	if (!imxpd)
331		return -ENOMEM;
332
333	/* port@1 is the output port */
334	ret = drm_of_find_panel_or_bridge(np, 1, 0, &imxpd->panel,
335					  &imxpd->next_bridge);
336	if (ret && ret != -ENODEV)
337		return ret;
338
339	edidp = of_get_property(np, "edid", &edid_len);
340	if (edidp)
341		imxpd->edid = devm_kmemdup(dev, edidp, edid_len, GFP_KERNEL);
342
343	ret = of_property_read_string(np, "interface-pix-fmt", &fmt);
344	if (!ret) {
345		if (!strcmp(fmt, "rgb24"))
346			bus_format = MEDIA_BUS_FMT_RGB888_1X24;
347		else if (!strcmp(fmt, "rgb565"))
348			bus_format = MEDIA_BUS_FMT_RGB565_1X16;
349		else if (!strcmp(fmt, "bgr666"))
350			bus_format = MEDIA_BUS_FMT_RGB666_1X18;
351		else if (!strcmp(fmt, "lvds666"))
352			bus_format = MEDIA_BUS_FMT_RGB666_1X24_CPADHI;
353	}
354	imxpd->bus_format = bus_format;
355
 
 
 
 
 
356	imxpd->dev = dev;
357
358	platform_set_drvdata(pdev, imxpd);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
360	return component_add(dev, &imx_pd_ops);
 
 
361}
362
363static int imx_pd_remove(struct platform_device *pdev)
364{
365	component_del(&pdev->dev, &imx_pd_ops);
366
367	return 0;
368}
369
370static const struct of_device_id imx_pd_dt_ids[] = {
371	{ .compatible = "fsl,imx-parallel-display", },
372	{ /* sentinel */ }
373};
374MODULE_DEVICE_TABLE(of, imx_pd_dt_ids);
375
376static struct platform_driver imx_pd_driver = {
377	.probe		= imx_pd_probe,
378	.remove		= imx_pd_remove,
379	.driver		= {
380		.of_match_table = imx_pd_dt_ids,
381		.name	= "imx-parallel-display",
382	},
383};
384
385module_platform_driver(imx_pd_driver);
386
387MODULE_DESCRIPTION("i.MX parallel display driver");
388MODULE_AUTHOR("Sascha Hauer, Pengutronix");
389MODULE_LICENSE("GPL");
390MODULE_ALIAS("platform:imx-parallel-display");