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);
217 int dss_suspend_all_devices(void);
218 int dss_resume_all_devices(void);
219 void dss_disable_all_devices(void);
221 int dss_init_device(struct platform_device *pdev,
222 struct omap_dss_device *dssdev);
223 void dss_uninit_device(struct platform_device *pdev,
224 struct omap_dss_device *dssdev);
226 int display_init_sysfs(struct platform_device *pdev,
227 struct omap_dss_device *dssdev);
228 void display_uninit_sysfs(struct platform_device *pdev,
229 struct omap_dss_device *dssdev);
232 int dss_init_overlay_managers(struct platform_device *pdev);
233 void dss_uninit_overlay_managers(struct platform_device *pdev);
234 int dss_mgr_simple_check(struct omap_overlay_manager *mgr,
235 const struct omap_overlay_manager_info *info);
236 int dss_mgr_check_timings(struct omap_overlay_manager *mgr,
237 const struct omap_video_timings *timings);
238 int dss_mgr_check(struct omap_overlay_manager *mgr,
239 struct omap_overlay_manager_info *info,
240 const struct omap_video_timings *mgr_timings,
241 const struct dss_lcd_mgr_config *config,
242 struct omap_overlay_info **overlay_infos);
244 static inline bool dss_mgr_is_lcd(enum omap_channel id)
246 if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
247 id == OMAP_DSS_CHANNEL_LCD3)
253 int dss_manager_kobj_init(struct omap_overlay_manager *mgr,
254 struct platform_device *pdev);
255 void dss_manager_kobj_uninit(struct omap_overlay_manager *mgr);
258 void dss_init_overlays(struct platform_device *pdev);
259 void dss_uninit_overlays(struct platform_device *pdev);
260 void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr);
261 int dss_ovl_simple_check(struct omap_overlay *ovl,
262 const struct omap_overlay_info *info);
263 int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
264 const struct omap_video_timings *mgr_timings);
265 bool dss_ovl_use_replication(struct dss_lcd_mgr_config config,
266 enum omap_color_mode mode);
267 int dss_overlay_kobj_init(struct omap_overlay *ovl,
268 struct platform_device *pdev);
269 void dss_overlay_kobj_uninit(struct omap_overlay *ovl);
272 int dss_init_platform_driver(void) __init;
273 void dss_uninit_platform_driver(void);
275 int dss_dpi_select_source(enum omap_channel channel);
276 void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
277 enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
278 const char *dss_get_generic_clk_source_name(enum omap_dss_clk_source clk_src);
279 void dss_dump_clocks(struct seq_file *s);
281 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
282 void dss_debug_dump_clocks(struct seq_file *s);
285 int dss_get_ctx_loss_count(void);
287 void dss_sdi_init(int datapairs);
288 int dss_sdi_enable(void);
289 void dss_sdi_disable(void);
291 void dss_select_dsi_clk_source(int dsi_module,
292 enum omap_dss_clk_source clk_src);
293 void dss_select_lcd_clk_source(enum omap_channel channel,
294 enum omap_dss_clk_source clk_src);
295 enum omap_dss_clk_source dss_get_dispc_clk_source(void);
296 enum omap_dss_clk_source dss_get_dsi_clk_source(int dsi_module);
297 enum omap_dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
299 void dss_set_venc_output(enum omap_dss_venc_type type);
300 void dss_set_dac_pwrdn_bgz(bool enable);
302 unsigned long dss_get_dpll4_rate(void);
303 int dss_calc_clock_rates(struct dss_clock_info *cinfo);
304 int dss_set_clock_div(struct dss_clock_info *cinfo);
305 int dss_calc_clock_div(unsigned long req_pck, struct dss_clock_info *dss_cinfo,
306 struct dispc_clock_info *dispc_cinfo);
309 int sdi_init_platform_driver(void) __init;
310 void sdi_uninit_platform_driver(void) __exit;
313 #ifdef CONFIG_OMAP2_DSS_DSI
316 struct file_operations;
318 int dsi_init_platform_driver(void) __init;
319 void dsi_uninit_platform_driver(void) __exit;
321 int dsi_runtime_get(struct platform_device *dsidev);
322 void dsi_runtime_put(struct platform_device *dsidev);
324 void dsi_dump_clocks(struct seq_file *s);
326 void dsi_irq_handler(void);
327 u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt);
329 unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev);
330 int dsi_pll_set_clock_div(struct platform_device *dsidev,
331 struct dsi_clock_info *cinfo);
332 int dsi_pll_calc_clock_div_pck(struct platform_device *dsidev,
333 unsigned long req_pck, struct dsi_clock_info *cinfo,
334 struct dispc_clock_info *dispc_cinfo);
335 int dsi_pll_init(struct platform_device *dsidev, bool enable_hsclk,
337 void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes);
338 void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev);
339 void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev);
340 struct platform_device *dsi_get_dsidev_from_id(int module);
342 static inline int dsi_runtime_get(struct platform_device *dsidev)
346 static inline void dsi_runtime_put(struct platform_device *dsidev)
349 static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
351 WARN("%s: DSI not compiled in, returning pixel_size as 0\n", __func__);
354 static inline unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
356 WARN("%s: DSI not compiled in, returning rate as 0\n", __func__);
359 static inline int dsi_pll_set_clock_div(struct platform_device *dsidev,
360 struct dsi_clock_info *cinfo)
362 WARN("%s: DSI not compiled in\n", __func__);
365 static inline int dsi_pll_calc_clock_div_pck(struct platform_device *dsidev,
366 unsigned long req_pck,
367 struct dsi_clock_info *dsi_cinfo,
368 struct dispc_clock_info *dispc_cinfo)
370 WARN("%s: DSI not compiled in\n", __func__);
373 static inline int dsi_pll_init(struct platform_device *dsidev,
374 bool enable_hsclk, bool enable_hsdiv)
376 WARN("%s: DSI not compiled in\n", __func__);
379 static inline void dsi_pll_uninit(struct platform_device *dsidev,
380 bool disconnect_lanes)
383 static inline void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev)
386 static inline void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev)
389 static inline struct platform_device *dsi_get_dsidev_from_id(int module)
396 int dpi_init_platform_driver(void) __init;
397 void dpi_uninit_platform_driver(void) __exit;
400 int dispc_init_platform_driver(void) __init;
401 void dispc_uninit_platform_driver(void) __exit;
402 void dispc_dump_clocks(struct seq_file *s);
403 u32 dispc_read_irqstatus(void);
404 void dispc_clear_irqstatus(u32 mask);
405 u32 dispc_read_irqenable(void);
406 void dispc_write_irqenable(u32 mask);
408 int dispc_runtime_get(void);
409 void dispc_runtime_put(void);
411 void dispc_enable_sidle(void);
412 void dispc_disable_sidle(void);
414 void dispc_lcd_enable_signal(bool enable);
415 void dispc_pck_free_enable(bool enable);
416 void dispc_enable_fifomerge(bool enable);
417 void dispc_enable_gamma_table(bool enable);
418 void dispc_set_loadmode(enum omap_dss_load_mode mode);
420 bool dispc_mgr_timings_ok(enum omap_channel channel,
421 const struct omap_video_timings *timings);
422 unsigned long dispc_fclk_rate(void);
423 void dispc_find_clk_divs(unsigned long req_pck, unsigned long fck,
424 struct dispc_clock_info *cinfo);
425 int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
426 struct dispc_clock_info *cinfo);
429 void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high);
430 void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane,
431 u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
433 int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
434 bool replication, const struct omap_video_timings *mgr_timings,
436 int dispc_ovl_enable(enum omap_plane plane, bool enable);
437 bool dispc_ovl_enabled(enum omap_plane plane);
438 void dispc_ovl_set_channel_out(enum omap_plane plane,
439 enum omap_channel channel);
441 u32 dispc_mgr_get_vsync_irq(enum omap_channel channel);
442 u32 dispc_mgr_get_framedone_irq(enum omap_channel channel);
443 u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel);
444 bool dispc_mgr_go_busy(enum omap_channel channel);
445 void dispc_mgr_go(enum omap_channel channel);
446 void dispc_mgr_enable(enum omap_channel channel, bool enable);
447 bool dispc_mgr_is_enabled(enum omap_channel channel);
448 void dispc_mgr_enable_sync(enum omap_channel channel);
449 void dispc_mgr_disable_sync(enum omap_channel channel);
450 void dispc_mgr_set_lcd_config(enum omap_channel channel,
451 const struct dss_lcd_mgr_config *config);
452 void dispc_mgr_set_timings(enum omap_channel channel,
453 const struct omap_video_timings *timings);
454 unsigned long dispc_mgr_lclk_rate(enum omap_channel channel);
455 unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
456 unsigned long dispc_core_clk_rate(void);
457 void dispc_mgr_set_clock_div(enum omap_channel channel,
458 const struct dispc_clock_info *cinfo);
459 int dispc_mgr_get_clock_div(enum omap_channel channel,
460 struct dispc_clock_info *cinfo);
461 void dispc_mgr_setup(enum omap_channel channel,
462 const struct omap_overlay_manager_info *info);
464 u32 dispc_wb_get_framedone_irq(void);
465 bool dispc_wb_go_busy(void);
466 void dispc_wb_go(void);
467 void dispc_wb_enable(bool enable);
468 bool dispc_wb_is_enabled(void);
469 void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
470 int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
471 bool mem_to_mem, const struct omap_video_timings *timings);
474 #ifdef CONFIG_OMAP2_DSS_VENC
475 int venc_init_platform_driver(void) __init;
476 void venc_uninit_platform_driver(void) __exit;
477 unsigned long venc_get_pixel_clock(void);
479 static inline unsigned long venc_get_pixel_clock(void)
481 WARN("%s: VENC not compiled in, returning pclk as 0\n", __func__);
485 int omapdss_venc_display_enable(struct omap_dss_device *dssdev);
486 void omapdss_venc_display_disable(struct omap_dss_device *dssdev);
487 void omapdss_venc_set_timings(struct omap_dss_device *dssdev,
488 struct omap_video_timings *timings);
489 int omapdss_venc_check_timings(struct omap_dss_device *dssdev,
490 struct omap_video_timings *timings);
491 u32 omapdss_venc_get_wss(struct omap_dss_device *dssdev);
492 int omapdss_venc_set_wss(struct omap_dss_device *dssdev, u32 wss);
493 void omapdss_venc_set_type(struct omap_dss_device *dssdev,
494 enum omap_dss_venc_type type);
495 void omapdss_venc_invert_vid_out_polarity(struct omap_dss_device *dssdev,
496 bool invert_polarity);
497 int venc_panel_init(void);
498 void venc_panel_exit(void);
501 #ifdef CONFIG_OMAP4_DSS_HDMI
502 int hdmi_init_platform_driver(void) __init;
503 void hdmi_uninit_platform_driver(void) __exit;
504 unsigned long hdmi_get_pixel_clock(void);
506 static inline unsigned long hdmi_get_pixel_clock(void)
508 WARN("%s: HDMI not compiled in, returning pclk as 0\n", __func__);
512 int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev);
513 void omapdss_hdmi_display_disable(struct omap_dss_device *dssdev);
514 int omapdss_hdmi_core_enable(struct omap_dss_device *dssdev);
515 void omapdss_hdmi_core_disable(struct omap_dss_device *dssdev);
516 void omapdss_hdmi_display_set_timing(struct omap_dss_device *dssdev,
517 struct omap_video_timings *timings);
518 int omapdss_hdmi_display_check_timing(struct omap_dss_device *dssdev,
519 struct omap_video_timings *timings);
520 int omapdss_hdmi_read_edid(u8 *buf, int len);
521 bool omapdss_hdmi_detect(void);
522 int hdmi_panel_init(void);
523 void hdmi_panel_exit(void);
524 #ifdef CONFIG_OMAP4_DSS_HDMI_AUDIO
525 int hdmi_audio_enable(void);
526 void hdmi_audio_disable(void);
527 int hdmi_audio_start(void);
528 void hdmi_audio_stop(void);
529 bool hdmi_mode_has_audio(void);
530 int hdmi_audio_config(struct omap_dss_audio *audio);
534 int rfbi_init_platform_driver(void) __init;
535 void rfbi_uninit_platform_driver(void) __exit;
538 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
539 static inline void dss_collect_irq_stats(u32 irqstatus, unsigned *irq_arr)
542 for (b = 0; b < 32; ++b) {
543 if (irqstatus & (1 << b))