2 * linux/drivers/video/omap2/dss/dss.h
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
7 * Some code and ideas taken from drivers/video/omap/ driver
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
30 #ifdef DSS_SUBSYS_NAME
31 #define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt
33 #define pr_fmt(fmt) fmt
36 #define DSSDBG(format, ...) \
37 pr_debug(format, ## __VA_ARGS__)
39 #ifdef DSS_SUBSYS_NAME
40 #define DSSERR(format, ...) \
41 printk(KERN_ERR "omapdss " DSS_SUBSYS_NAME " error: " format, \
44 #define DSSERR(format, ...) \
45 printk(KERN_ERR "omapdss error: " format, ## __VA_ARGS__)
48 #ifdef DSS_SUBSYS_NAME
49 #define DSSINFO(format, ...) \
50 printk(KERN_INFO "omapdss " DSS_SUBSYS_NAME ": " format, \
53 #define DSSINFO(format, ...) \
54 printk(KERN_INFO "omapdss: " format, ## __VA_ARGS__)
57 #ifdef DSS_SUBSYS_NAME
58 #define DSSWARN(format, ...) \
59 printk(KERN_WARNING "omapdss " DSS_SUBSYS_NAME ": " format, \
62 #define DSSWARN(format, ...) \
63 printk(KERN_WARNING "omapdss: " format, ## __VA_ARGS__)
66 /* OMAP TRM gives bitfields as start:end, where start is the higher bit
67 number. For example 7:0 */
68 #define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end))
69 #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
70 #define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
71 #define FLD_MOD(orig, val, start, end) \
72 (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
74 enum dss_io_pad_mode {
75 DSS_IO_PAD_MODE_RESET,
77 DSS_IO_PAD_MODE_BYPASS,
80 enum dss_hdmi_venc_clk_source_select {
85 enum dss_dsi_content_type {
87 DSS_DSI_CONTENT_GENERIC,
90 enum dss_writeback_channel {
101 struct dss_clock_info {
102 /* rates that we get with dividers below */
109 struct dispc_clock_info {
110 /* rates that we get with dividers below */
119 struct dsi_clock_info {
120 /* rates that we get with dividers below */
122 unsigned long clkin4ddr;
124 unsigned long dsi_pll_hsdiv_dispc_clk; /* OMAP3: DSI1_PLL_CLK
125 * OMAP4: PLLx_CLK1 */
126 unsigned long dsi_pll_hsdiv_dsi_clk; /* OMAP3: DSI2_PLL_CLK
127 * OMAP4: PLLx_CLK2 */
128 unsigned long lp_clk;
133 u16 regm_dispc; /* OMAP3: REGM3
135 u16 regm_dsi; /* OMAP3: REGM4
146 struct dss_lcd_mgr_config {
147 enum dss_io_pad_mode io_pad_mode;
152 struct dispc_clock_info clock_info;
154 int video_port_width;
156 int lcden_sig_polarity;
160 struct platform_device;
163 struct platform_device *dss_get_core_pdev(void);
164 struct bus_type *dss_get_bus(void);
165 struct regulator *dss_get_vdds_dsi(void);
166 struct regulator *dss_get_vdds_sdi(void);
167 int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask);
168 void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask);
169 int dss_set_min_bus_tput(struct device *dev, unsigned long tput);
170 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
172 struct omap_dss_device *dss_alloc_and_init_device(struct device *parent);
173 int dss_add_device(struct omap_dss_device *dssdev);
174 void dss_unregister_device(struct omap_dss_device *dssdev);
175 void dss_unregister_child_devices(struct device *parent);
176 void dss_put_device(struct omap_dss_device *dssdev);
177 void dss_copy_device_pdata(struct omap_dss_device *dst,
178 const struct omap_dss_device *src);
181 void dss_apply_init(void);
182 int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr);
183 int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl);
184 void dss_mgr_start_update(struct omap_overlay_manager *mgr);
185 int omap_dss_mgr_apply(struct omap_overlay_manager *mgr);
187 int dss_mgr_enable(struct omap_overlay_manager *mgr);
188 void dss_mgr_disable(struct omap_overlay_manager *mgr);
189 int dss_mgr_set_info(struct omap_overlay_manager *mgr,
190 struct omap_overlay_manager_info *info);
191 void dss_mgr_get_info(struct omap_overlay_manager *mgr,
192 struct omap_overlay_manager_info *info);
193 int dss_mgr_set_output(struct omap_overlay_manager *mgr,
194 struct omap_dss_output *output);
195 int dss_mgr_unset_output(struct omap_overlay_manager *mgr);
196 void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
197 const struct omap_video_timings *timings);
198 void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
199 const struct dss_lcd_mgr_config *config);
201 bool dss_ovl_is_enabled(struct omap_overlay *ovl);
202 int dss_ovl_enable(struct omap_overlay *ovl);
203 int dss_ovl_disable(struct omap_overlay *ovl);
204 int dss_ovl_set_info(struct omap_overlay *ovl,
205 struct omap_overlay_info *info);
206 void dss_ovl_get_info(struct omap_overlay *ovl,
207 struct omap_overlay_info *info);
208 int dss_ovl_set_manager(struct omap_overlay *ovl,
209 struct omap_overlay_manager *mgr);
210 int dss_ovl_unset_manager(struct omap_overlay *ovl);
213 void dss_register_output(struct omap_dss_output *out);
214 void dss_unregister_output(struct omap_dss_output *out);
215 struct omap_dss_output *omapdss_get_output_from_dssdev(struct omap_dss_device *dssdev);
218 int dss_suspend_all_devices(void);
219 int dss_resume_all_devices(void);
220 void dss_disable_all_devices(void);
222 int dss_init_device(struct platform_device *pdev,
223 struct omap_dss_device *dssdev);
224 void dss_uninit_device(struct platform_device *pdev,
225 struct omap_dss_device *dssdev);
227 int display_init_sysfs(struct platform_device *pdev,
228 struct omap_dss_device *dssdev);
229 void display_uninit_sysfs(struct platform_device *pdev,
230 struct omap_dss_device *dssdev);
233 int dss_init_overlay_managers(struct platform_device *pdev);
234 void dss_uninit_overlay_managers(struct platform_device *pdev);
235 int dss_mgr_simple_check(struct omap_overlay_manager *mgr,
236 const struct omap_overlay_manager_info *info);
237 int dss_mgr_check_timings(struct omap_overlay_manager *mgr,
238 const struct omap_video_timings *timings);
239 int dss_mgr_check(struct omap_overlay_manager *mgr,
240 struct omap_overlay_manager_info *info,
241 const struct omap_video_timings *mgr_timings,
242 const struct dss_lcd_mgr_config *config,
243 struct omap_overlay_info **overlay_infos);
245 static inline bool dss_mgr_is_lcd(enum omap_channel id)
247 if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
248 id == OMAP_DSS_CHANNEL_LCD3)
254 int dss_manager_kobj_init(struct omap_overlay_manager *mgr,
255 struct platform_device *pdev);
256 void dss_manager_kobj_uninit(struct omap_overlay_manager *mgr);
259 void dss_init_overlays(struct platform_device *pdev);
260 void dss_uninit_overlays(struct platform_device *pdev);
261 void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr);
262 int dss_ovl_simple_check(struct omap_overlay *ovl,
263 const struct omap_overlay_info *info);
264 int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
265 const struct omap_video_timings *mgr_timings);
266 bool dss_ovl_use_replication(struct dss_lcd_mgr_config config,
267 enum omap_color_mode mode);
268 int dss_overlay_kobj_init(struct omap_overlay *ovl,
269 struct platform_device *pdev);
270 void dss_overlay_kobj_uninit(struct omap_overlay *ovl);
273 int dss_init_platform_driver(void) __init;
274 void dss_uninit_platform_driver(void);
276 int dss_dpi_select_source(enum omap_channel channel);
277 void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
278 enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
279 const char *dss_get_generic_clk_source_name(enum omap_dss_clk_source clk_src);
280 void dss_dump_clocks(struct seq_file *s);
282 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
283 void dss_debug_dump_clocks(struct seq_file *s);
286 int dss_get_ctx_loss_count(void);
288 void dss_sdi_init(int datapairs);
289 int dss_sdi_enable(void);
290 void dss_sdi_disable(void);
292 void dss_select_dsi_clk_source(int dsi_module,
293 enum omap_dss_clk_source clk_src);
294 void dss_select_lcd_clk_source(enum omap_channel channel,
295 enum omap_dss_clk_source clk_src);
296 enum omap_dss_clk_source dss_get_dispc_clk_source(void);
297 enum omap_dss_clk_source dss_get_dsi_clk_source(int dsi_module);
298 enum omap_dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
300 void dss_set_venc_output(enum omap_dss_venc_type type);
301 void dss_set_dac_pwrdn_bgz(bool enable);
303 unsigned long dss_get_dpll4_rate(void);
304 int dss_calc_clock_rates(struct dss_clock_info *cinfo);
305 int dss_set_clock_div(struct dss_clock_info *cinfo);
306 int dss_calc_clock_div(unsigned long req_pck, struct dss_clock_info *dss_cinfo,
307 struct dispc_clock_info *dispc_cinfo);
310 int sdi_init_platform_driver(void) __init;
311 void sdi_uninit_platform_driver(void) __exit;
314 #ifdef CONFIG_OMAP2_DSS_DSI
317 struct file_operations;
319 int dsi_init_platform_driver(void) __init;
320 void dsi_uninit_platform_driver(void) __exit;
322 int dsi_runtime_get(struct platform_device *dsidev);
323 void dsi_runtime_put(struct platform_device *dsidev);
325 void dsi_dump_clocks(struct seq_file *s);
327 void dsi_irq_handler(void);
328 u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt);
330 unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev);
331 int dsi_pll_set_clock_div(struct platform_device *dsidev,
332 struct dsi_clock_info *cinfo);
333 int dsi_pll_calc_clock_div_pck(struct platform_device *dsidev,
334 unsigned long req_pck, struct dsi_clock_info *cinfo,
335 struct dispc_clock_info *dispc_cinfo);
336 int dsi_pll_init(struct platform_device *dsidev, bool enable_hsclk,
338 void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes);
339 void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev);
340 void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev);
341 struct platform_device *dsi_get_dsidev_from_id(int module);
343 static inline int dsi_runtime_get(struct platform_device *dsidev)
347 static inline void dsi_runtime_put(struct platform_device *dsidev)
350 static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
352 WARN("%s: DSI not compiled in, returning pixel_size as 0\n", __func__);
355 static inline unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
357 WARN("%s: DSI not compiled in, returning rate as 0\n", __func__);
360 static inline int dsi_pll_set_clock_div(struct platform_device *dsidev,
361 struct dsi_clock_info *cinfo)
363 WARN("%s: DSI not compiled in\n", __func__);
366 static inline int dsi_pll_calc_clock_div_pck(struct platform_device *dsidev,
367 unsigned long req_pck,
368 struct dsi_clock_info *dsi_cinfo,
369 struct dispc_clock_info *dispc_cinfo)
371 WARN("%s: DSI not compiled in\n", __func__);
374 static inline int dsi_pll_init(struct platform_device *dsidev,
375 bool enable_hsclk, bool enable_hsdiv)
377 WARN("%s: DSI not compiled in\n", __func__);
380 static inline void dsi_pll_uninit(struct platform_device *dsidev,
381 bool disconnect_lanes)
384 static inline void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev)
387 static inline void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev)
390 static inline struct platform_device *dsi_get_dsidev_from_id(int module)
397 int dpi_init_platform_driver(void) __init;
398 void dpi_uninit_platform_driver(void) __exit;
401 int dispc_init_platform_driver(void) __init;
402 void dispc_uninit_platform_driver(void) __exit;
403 void dispc_dump_clocks(struct seq_file *s);
404 u32 dispc_read_irqstatus(void);
405 void dispc_clear_irqstatus(u32 mask);
406 u32 dispc_read_irqenable(void);
407 void dispc_write_irqenable(u32 mask);
409 int dispc_runtime_get(void);
410 void dispc_runtime_put(void);
412 void dispc_enable_sidle(void);
413 void dispc_disable_sidle(void);
415 void dispc_lcd_enable_signal(bool enable);
416 void dispc_pck_free_enable(bool enable);
417 void dispc_enable_fifomerge(bool enable);
418 void dispc_enable_gamma_table(bool enable);
419 void dispc_set_loadmode(enum omap_dss_load_mode mode);
421 bool dispc_mgr_timings_ok(enum omap_channel channel,
422 const struct omap_video_timings *timings);
423 unsigned long dispc_fclk_rate(void);
424 void dispc_find_clk_divs(unsigned long req_pck, unsigned long fck,
425 struct dispc_clock_info *cinfo);
426 int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
427 struct dispc_clock_info *cinfo);
430 void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high);
431 void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane,
432 u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
434 int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
435 bool replication, const struct omap_video_timings *mgr_timings,
437 int dispc_ovl_enable(enum omap_plane plane, bool enable);
438 bool dispc_ovl_enabled(enum omap_plane plane);
439 void dispc_ovl_set_channel_out(enum omap_plane plane,
440 enum omap_channel channel);
442 u32 dispc_mgr_get_vsync_irq(enum omap_channel channel);
443 u32 dispc_mgr_get_framedone_irq(enum omap_channel channel);
444 u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel);
445 bool dispc_mgr_go_busy(enum omap_channel channel);
446 void dispc_mgr_go(enum omap_channel channel);
447 void dispc_mgr_enable(enum omap_channel channel, bool enable);
448 bool dispc_mgr_is_enabled(enum omap_channel channel);
449 void dispc_mgr_enable_sync(enum omap_channel channel);
450 void dispc_mgr_disable_sync(enum omap_channel channel);
451 void dispc_mgr_set_lcd_config(enum omap_channel channel,
452 const struct dss_lcd_mgr_config *config);
453 void dispc_mgr_set_timings(enum omap_channel channel,
454 const struct omap_video_timings *timings);
455 unsigned long dispc_mgr_lclk_rate(enum omap_channel channel);
456 unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
457 unsigned long dispc_core_clk_rate(void);
458 void dispc_mgr_set_clock_div(enum omap_channel channel,
459 const struct dispc_clock_info *cinfo);
460 int dispc_mgr_get_clock_div(enum omap_channel channel,
461 struct dispc_clock_info *cinfo);
462 void dispc_mgr_setup(enum omap_channel channel,
463 const struct omap_overlay_manager_info *info);
465 u32 dispc_wb_get_framedone_irq(void);
466 bool dispc_wb_go_busy(void);
467 void dispc_wb_go(void);
468 void dispc_wb_enable(bool enable);
469 bool dispc_wb_is_enabled(void);
470 void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
471 int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
472 bool mem_to_mem, const struct omap_video_timings *timings);
475 #ifdef CONFIG_OMAP2_DSS_VENC
476 int venc_init_platform_driver(void) __init;
477 void venc_uninit_platform_driver(void) __exit;
478 unsigned long venc_get_pixel_clock(void);
480 static inline unsigned long venc_get_pixel_clock(void)
482 WARN("%s: VENC not compiled in, returning pclk as 0\n", __func__);
486 int omapdss_venc_display_enable(struct omap_dss_device *dssdev);
487 void omapdss_venc_display_disable(struct omap_dss_device *dssdev);
488 void omapdss_venc_set_timings(struct omap_dss_device *dssdev,
489 struct omap_video_timings *timings);
490 int omapdss_venc_check_timings(struct omap_dss_device *dssdev,
491 struct omap_video_timings *timings);
492 u32 omapdss_venc_get_wss(struct omap_dss_device *dssdev);
493 int omapdss_venc_set_wss(struct omap_dss_device *dssdev, u32 wss);
494 void omapdss_venc_set_type(struct omap_dss_device *dssdev,
495 enum omap_dss_venc_type type);
496 void omapdss_venc_invert_vid_out_polarity(struct omap_dss_device *dssdev,
497 bool invert_polarity);
498 int venc_panel_init(void);
499 void venc_panel_exit(void);
502 #ifdef CONFIG_OMAP4_DSS_HDMI
503 int hdmi_init_platform_driver(void) __init;
504 void hdmi_uninit_platform_driver(void) __exit;
505 unsigned long hdmi_get_pixel_clock(void);
507 static inline unsigned long hdmi_get_pixel_clock(void)
509 WARN("%s: HDMI not compiled in, returning pclk as 0\n", __func__);
513 int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev);
514 void omapdss_hdmi_display_disable(struct omap_dss_device *dssdev);
515 int omapdss_hdmi_core_enable(struct omap_dss_device *dssdev);
516 void omapdss_hdmi_core_disable(struct omap_dss_device *dssdev);
517 void omapdss_hdmi_display_set_timing(struct omap_dss_device *dssdev,
518 struct omap_video_timings *timings);
519 int omapdss_hdmi_display_check_timing(struct omap_dss_device *dssdev,
520 struct omap_video_timings *timings);
521 int omapdss_hdmi_read_edid(u8 *buf, int len);
522 bool omapdss_hdmi_detect(void);
523 int hdmi_panel_init(void);
524 void hdmi_panel_exit(void);
525 #ifdef CONFIG_OMAP4_DSS_HDMI_AUDIO
526 int hdmi_audio_enable(void);
527 void hdmi_audio_disable(void);
528 int hdmi_audio_start(void);
529 void hdmi_audio_stop(void);
530 bool hdmi_mode_has_audio(void);
531 int hdmi_audio_config(struct omap_dss_audio *audio);
535 int rfbi_init_platform_driver(void) __init;
536 void rfbi_uninit_platform_driver(void) __exit;
539 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
540 static inline void dss_collect_irq_stats(u32 irqstatus, unsigned *irq_arr)
543 for (b = 0; b < 32; ++b) {
544 if (irqstatus & (1 << b))