drm/omap: Make omapdss API more generic, especially the IRQ handling
Subsystems (3)
PATCH v2 3/3 drm/omap: Make omapdss API more generic, especially the IRQ handling
In reply to a message not in the archiveThe new omapdss API is HW independent and cleans up some of the DSS5 specific hacks from the omapdrm side and gets rid off the DSS5 IRQ register bits and replace them with HW independent generic u64 based macros. This new macros make it more straight forward to implement the IRQ code for the future DSS versions that do not share the same register structure as DSS2 to DSS5 has.
Signed-off-by Jyri Sarha <[email protected]>
--- drivers/gpu/drm/omapdrm/dss/dispc.c | 148 ++++++++++++++++++++++++++++------ drivers/gpu/drm/omapdrm/dss/dispc.h | 33 ++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 64 +++++++-------- drivers/gpu/drm/omapdrm/omap_crtc.c | 16 ++-- drivers/gpu/drm/omapdrm/omap_crtc.h | 2 +- drivers/gpu/drm/omapdrm/omap_drv.h | 3 +- drivers/gpu/drm/omapdrm/omap_irq.c | 136 +++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_irq.h | 2 +- drivers/gpu/drm/omapdrm/omap_plane.c | 7 ++ drivers/gpu/drm/omapdrm/omap_plane.h | 1 + 10 files changed, 267 insertions(+), 145 deletions(-)
drivers/gpu/drm/omapdrm/dss/dispc.c +123 -25
@@ -698,27 +698,12 @@ static const char *dispc_get_mgr_name(enum omap_channel channel)return mgr_desc[channel].name; } -static u32 dispc_mgr_get_vsync_irq (enum omap_channel channel) -{ -return mgr_desc[channel].vsync_irq; -} - -static u32 dispc_mgr_get_framedone_irq (enum omap_channel channel) +static bool dispc_mgr_has_framedone (enum omap_channel channel) {if (channel ==OMAP_DSS_CHANNEL_DIGIT && dispc.feat->no_framedone_tv) -return 0 ; - -return mgr_desc[channel].framedone_irq; -} - -static u32 dispc_mgr_get_sync_lost_irq (enum omap_channel channel) -{ -return mgr_desc[channel].sync_lost_irq; -} +return false; -u32 dispc_wb_get_framedone_irq (void ) -{ -return DISPC_IRQ_FRAMEDONEWB ; +return true; }static void dispc_mgr_enable (enum omap_channel channel,bool enable)
@@ -3604,6 +3589,121 @@ static void dispc_write_irqenable(u32 mask)dispc_read_reg (DISPC_IRQENABLE ); } +static u64 dispc_hw_to_api_irq (u32 hw) +{ +u64 api =0 ; + +if (hw &DISPC_IRQ_OCP_ERR ) + api |=DSS_IRQ_DEVICE_OCP_ERR ; + +if (hw &DISPC_IRQ_FRAMEDONE ) + api |=DSS_IRQ_MGR_FRAME_DONE (0 ); +if (hw &DISPC_IRQ_VSYNC ) + api |=DSS_IRQ_MGR_VSYNC_EVEN (0 ); +if (hw &DISPC_IRQ_SYNC_LOST ) + api |=DSS_IRQ_MGR_SYNC_LOST (0 ); + +if (hw &DISPC_IRQ_EVSYNC_EVEN ) + api |=DSS_IRQ_MGR_VSYNC_EVEN (1 ); +if (hw &DISPC_IRQ_EVSYNC_ODD ) + api |=DSS_IRQ_MGR_VSYNC_ODD (1 ); +if (hw &DISPC_IRQ_SYNC_LOST_DIGIT ) + api |=DSS_IRQ_MGR_SYNC_LOST (1 ); +if (hw &DISPC_IRQ_FRAMEDONETV ) + api |=DSS_IRQ_MGR_FRAME_DONE (1 ); + +if (hw &DISPC_IRQ_SYNC_LOST2 ) + api |=DSS_IRQ_MGR_SYNC_LOST (2 ); +if (hw &DISPC_IRQ_VSYNC2 ) + api |=DSS_IRQ_MGR_VSYNC_EVEN (2 ); +if (hw &DISPC_IRQ_FRAMEDONE2 ) + api |=DSS_IRQ_MGR_FRAME_DONE (2 ); + +if (hw &DISPC_IRQ_SYNC_LOST3 ) + api |=DSS_IRQ_MGR_SYNC_LOST (3 ); +if (hw &DISPC_IRQ_VSYNC3 ) + api |=DSS_IRQ_MGR_VSYNC_EVEN (3 ); +if (hw &DISPC_IRQ_FRAMEDONE3 ) + api |=DSS_IRQ_MGR_FRAME_DONE (3 ); + +if (hw &DISPC_IRQ_GFX_FIFO_UNDERFLOW ) + api |=DSS_IRQ_OVL_FIFO_UNDERFLOW (0 ); +if (hw &DISPC_IRQ_VID1_FIFO_UNDERFLOW ) + api |=DSS_IRQ_OVL_FIFO_UNDERFLOW (1 ); +if (hw &DISPC_IRQ_VID2_FIFO_UNDERFLOW ) + api |=DSS_IRQ_OVL_FIFO_UNDERFLOW (2 ); +if (hw &DISPC_IRQ_VID3_FIFO_UNDERFLOW ) + api |=DSS_IRQ_OVL_FIFO_UNDERFLOW (3 ); + +return api; +} + +static u32 dispc_api_to_hw_irq (u64 api) +{ +u32 hw =0 ; + +if (api &DSS_IRQ_DEVICE_OCP_ERR ) + hw |=DISPC_IRQ_OCP_ERR ; + +if (api &DSS_IRQ_MGR_FRAME_DONE (0 )) + hw |=DISPC_IRQ_FRAMEDONE ; +if (api &DSS_IRQ_MGR_VSYNC_EVEN (0 )) + hw |=DISPC_IRQ_VSYNC ; +if (api &DSS_IRQ_MGR_SYNC_LOST (0 )) + hw |=DISPC_IRQ_SYNC_LOST ; + +if (api &DSS_IRQ_MGR_VSYNC_EVEN (1 )) + hw |=DISPC_IRQ_EVSYNC_EVEN ; +if (api &DSS_IRQ_MGR_VSYNC_ODD (1 )) + hw |=DISPC_IRQ_EVSYNC_ODD ; +if (api &DSS_IRQ_MGR_SYNC_LOST (1 )) + hw |=DISPC_IRQ_SYNC_LOST_DIGIT ; +if (api &DSS_IRQ_MGR_FRAME_DONE (1 )) + hw |=DISPC_IRQ_FRAMEDONETV ; + +if (api &DSS_IRQ_MGR_SYNC_LOST (2 )) + hw |=DISPC_IRQ_SYNC_LOST2 ; +if (api &DSS_IRQ_MGR_VSYNC_EVEN (2 )) + hw |=DISPC_IRQ_VSYNC2 ; +if (api &DSS_IRQ_MGR_FRAME_DONE (2 )) + hw |=DISPC_IRQ_FRAMEDONE2 ; + +if (api &DSS_IRQ_MGR_SYNC_LOST (3 )) + hw |=DISPC_IRQ_SYNC_LOST3 ; +if (api &DSS_IRQ_MGR_VSYNC_EVEN (3 )) + hw |=DISPC_IRQ_VSYNC3 ; +if (api &DSS_IRQ_MGR_FRAME_DONE (3 )) + hw |=DISPC_IRQ_FRAMEDONE3 ; + +if (api &DSS_IRQ_OVL_FIFO_UNDERFLOW (0 )) + hw |=DISPC_IRQ_GFX_FIFO_UNDERFLOW ; +if (api &DSS_IRQ_OVL_FIFO_UNDERFLOW (1 )) + hw |=DISPC_IRQ_VID1_FIFO_UNDERFLOW ; +if (api &DSS_IRQ_OVL_FIFO_UNDERFLOW (2 )) + hw |=DISPC_IRQ_VID2_FIFO_UNDERFLOW ; +if (api &DSS_IRQ_OVL_FIFO_UNDERFLOW (3 )) + hw |=DISPC_IRQ_VID3_FIFO_UNDERFLOW ; + +return hw; +} + +static u64 dispc_api_read_irqstatus (u64 clearmask) +{ +u32 hw_clearmask =dispc_api_to_hw_irq (clearmask); +u32 hw_status =dispc_read_irqstatus (); + +dispc_clear_irqstatus (hw_clearmask & hw_status); + +return dispc_hw_to_api_irq (hw_status); +} + +static void dispc_api_write_irqenable (u64 enable) +{ +u32 hw_enable =dispc_api_to_hw_irq (enable); + +dispc_write_irqenable (hw_enable); +} +void dispc_enable_sidle (void ) {REG_FLD_MOD (DISPC_SYSCONFIG ,2 ,4 ,3 );/* SIDLEMODE: smart idle */
@@ -4453,7 +4553,7 @@ static void dispc_errata_i734_wa_fini(void)static void dispc_errata_i734_wa (void ) { -u32 framedone_irq =dispc_mgr_get_framedone_irq (OMAP_DSS_CHANNEL_LCD ); +u32 framedone_irq =DISPC_IRQ_FRAMEDONE ;struct omap_overlay_info ovli;struct dss_lcd_mgr_config lcd_conf;u32 gatestate;
@@ -4511,9 +4611,8 @@ static void dispc_errata_i734_wa(void) }static const struct dispc_ops dispc_ops = { - .read_irqstatus = dispc_read_irqstatus, - .clear_irqstatus = dispc_clear_irqstatus, - .write_irqenable = dispc_write_irqenable, + .read_irqstatus = dispc_api_read_irqstatus, + .write_irqenable = dispc_api_write_irqenable, .request_irq = dispc_request_irq, .free_irq = dispc_free_irq,
@@ -4527,13 +4626,12 @@ static void dispc_errata_i734_wa(void) .get_ovl_name = dispc_get_ovl_name, .get_mgr_name = dispc_get_mgr_name, + .mgr_has_framedone = dispc_mgr_has_framedone, + .get_memory_bandwidth_limit = dispc_get_memory_bandwidth_limit, .mgr_enable = dispc_mgr_enable, .mgr_is_enabled = dispc_mgr_is_enabled, - .mgr_get_vsync_irq = dispc_mgr_get_vsync_irq, - .mgr_get_framedone_irq = dispc_mgr_get_framedone_irq, - .mgr_get_sync_lost_irq = dispc_mgr_get_sync_lost_irq, .mgr_go_busy = dispc_mgr_go_busy, .mgr_go = dispc_mgr_go, .mgr_set_lcd_config = dispc_mgr_set_lcd_config,
drivers/gpu/drm/omapdrm/dss/dispc.h +33 -0
@@ -18,6 +18,39 @@#ifndef __OMAP2_DISPC_REG_H#define __OMAP2_DISPC_REG_H +/* DISPC IRQ bits */ +#define DISPC_IRQ_FRAMEDONE (1 << 0) +#define DISPC_IRQ_VSYNC (1 << 1) +#define DISPC_IRQ_EVSYNC_EVEN (1 << 2) +#define DISPC_IRQ_EVSYNC_ODD (1 << 3) +#define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4) +#define DISPC_IRQ_PROG_LINE_NUM (1 << 5) +#define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6) +#define DISPC_IRQ_GFX_END_WIN (1 << 7) +#define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8) +#define DISPC_IRQ_OCP_ERR (1 << 9) +#define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10) +#define DISPC_IRQ_VID1_END_WIN (1 << 11) +#define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12) +#define DISPC_IRQ_VID2_END_WIN (1 << 13) +#define DISPC_IRQ_SYNC_LOST (1 << 14) +#define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15) +#define DISPC_IRQ_WAKEUP (1 << 16) +#define DISPC_IRQ_SYNC_LOST2 (1 << 17) +#define DISPC_IRQ_VSYNC2 (1 << 18) +#define DISPC_IRQ_VID3_END_WIN (1 << 19) +#define DISPC_IRQ_VID3_FIFO_UNDERFLOW (1 << 20) +#define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21) +#define DISPC_IRQ_FRAMEDONE2 (1 << 22) +#define DISPC_IRQ_FRAMEDONEWB (1 << 23) +#define DISPC_IRQ_FRAMEDONETV (1 << 24) +#define DISPC_IRQ_WBBUFFEROVERFLOW (1 << 25) +#define DISPC_IRQ_WBUNCOMPLETEERROR (1 << 26) +#define DISPC_IRQ_SYNC_LOST3 (1 << 27) +#define DISPC_IRQ_VSYNC3 (1 << 28) +#define DISPC_IRQ_ACBIAS_COUNT_STAT3 (1 << 29) +#define DISPC_IRQ_FRAMEDONE3 (1 << 30) +/* DISPC common registers */ #define DISPC_REVISION 0x0000#define DISPC_SYSCONFIG 0x0010
drivers/gpu/drm/omapdrm/dss/omapdss.h +27 -37
86 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_crtc.c +9 -7
@@ -149,7 +149,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)struct omap_crtc *omap_crtc =to_omap_crtc (crtc);enum omap_channel channel = omap_crtc->channel;struct omap_irq_wait *wait; -u32 framedone_irq, vsync_irq; +u64 vsync_irq, framedone_irq;int ret;if (WARN_ON (omap_crtc->enabled == enable))
@@ -169,8 +169,10 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) omap_crtc->ignore_digit_sync_lost = true; } - framedone_irq = priv->dispc_ops->mgr_get_framedone_irq (channel); - vsync_irq = priv->dispc_ops->mgr_get_vsync_irq (channel); + + vsync_irq = (DSS_IRQ_MGR_VSYNC_EVEN (channel) | +DSS_IRQ_MGR_VSYNC_ODD (channel)); + framedone_irq =DSS_IRQ_MGR_FRAME_DONE (channel);if (enable) { wait =omap_irq_wait_init (dev, vsync_irq,1 );
@@ -184,7 +186,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)* even and odd frames. */ -if (framedone_irq) +if (priv->dispc_ops->mgr_has_framedone (channel)) wait =omap_irq_wait_init (dev, framedone_irq,1 );else wait =omap_irq_wait_init (dev, vsync_irq,2 );
@@ -272,17 +274,17 @@ static void omap_crtc_dss_unregister_framedone(* Setup, Flush and Page Flip */ -void omap_crtc_error_irq (struct drm_crtc *crtc,uint32_t irqstatus) +void omap_crtc_error_irq (struct drm_crtc *crtc,u64 irqstatus) {struct omap_crtc *omap_crtc =to_omap_crtc (crtc);if (omap_crtc->ignore_digit_sync_lost) { - irqstatus &= ~DISPC_IRQ_SYNC_LOST_DIGIT ; + irqstatus &= ~DSS_IRQ_MGR_SYNC_LOST (omap_crtc->channel);if (!irqstatus)return ; } -DRM_ERROR_RATELIMITED ("%s: errors: %08x\n" , omap_crtc->name, irqstatus); +DRM_ERROR_RATELIMITED ("%s: errors: %016llx\n" , omap_crtc->name, irqstatus); }void omap_crtc_vblank_irq (struct drm_crtc *crtc)
drivers/gpu/drm/omapdrm/omap_crtc.h +1 -1
@@ -37,7 +37,7 @@struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,struct omap_dss_device *dssdev);int omap_crtc_wait_pending (struct drm_crtc *crtc); -void omap_crtc_error_irq (struct drm_crtc *crtc,uint32_t irqstatus); +void omap_crtc_error_irq (struct drm_crtc *crtc,u64 irqstatus);void omap_crtc_vblank_irq (struct drm_crtc *crtc);#endif /* __OMAPDRM_CRTC_H__ */
drivers/gpu/drm/omapdrm/omap_drv.h +1 -2
@@ -81,8 +81,7 @@ struct omap_drm_private {/* irq handling: */ spinlock_t wait_lock;/* protects the wait_list */ struct list_head wait_list;/* list of omap_irq_wait */ -uint32_t irq_mask;/* enabled irqs in addition to wait_list */ - +u64 irq_mask;/* enabled irqs in addition to wait_list */ /* memory bandwidth limit if it is needed on the platform */ unsigned int max_bandwidth; };
drivers/gpu/drm/omapdrm/omap_irq.c +64 -72
266 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_irq.h +1 -1
@@ -32,7 +32,7 @@int omap_drm_irq_install (struct drm_device *dev);struct omap_irq_wait *omap_irq_wait_init (struct drm_device *dev, -uint32_t irqmask,int count); +u64 irqmask,int count);int omap_irq_wait (struct drm_device *dev,struct omap_irq_wait *wait,unsigned long timeout);
drivers/gpu/drm/omapdrm/omap_plane.c +7 -0
@@ -239,6 +239,13 @@ static int omap_plane_atomic_get_property(struct drm_plane *plane, .atomic_get_property = omap_plane_atomic_get_property, }; +enum omap_plane_id omap_plane_get_id (struct drm_plane *plane) +{ +struct omap_plane *omap_plane =to_omap_plane (plane); + +return omap_plane->id; +} +static const enum omap_plane_id plane_idx_to_id[] = {OMAP_DSS_GFX ,OMAP_DSS_VIDEO1 ,
drivers/gpu/drm/omapdrm/omap_plane.h +1 -0
@@ -33,5 +33,6 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, u32 possible_crtcs);void omap_plane_install_properties (struct drm_plane *plane,struct drm_mode_object *obj); +enum omap_plane_id omap_plane_get_id (struct drm_plane *plane);#endif /* __OMAPDRM_PLANE_H__ */
Signature · 9 lines
1.9.1 Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel