1*11696c5eSBiju Das /* SPDX-License-Identifier: GPL-2.0+ */ 2*11696c5eSBiju Das /* 3*11696c5eSBiju Das * R-Car Display Unit CRTCs 4*11696c5eSBiju Das * 5*11696c5eSBiju Das * Copyright (C) 2013-2015 Renesas Electronics Corporation 6*11696c5eSBiju Das * 7*11696c5eSBiju Das * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 8*11696c5eSBiju Das */ 9*11696c5eSBiju Das 10*11696c5eSBiju Das #ifndef __RCAR_DU_CRTC_H__ 11*11696c5eSBiju Das #define __RCAR_DU_CRTC_H__ 12*11696c5eSBiju Das 13*11696c5eSBiju Das #include <linux/mutex.h> 14*11696c5eSBiju Das #include <linux/spinlock.h> 15*11696c5eSBiju Das #include <linux/wait.h> 16*11696c5eSBiju Das 17*11696c5eSBiju Das #include <drm/drm_crtc.h> 18*11696c5eSBiju Das #include <drm/drm_writeback.h> 19*11696c5eSBiju Das 20*11696c5eSBiju Das #include <media/vsp1.h> 21*11696c5eSBiju Das 22*11696c5eSBiju Das struct rcar_du_group; 23*11696c5eSBiju Das struct rcar_du_vsp; 24*11696c5eSBiju Das 25*11696c5eSBiju Das /** 26*11696c5eSBiju Das * struct rcar_du_crtc - the CRTC, representing a DU superposition processor 27*11696c5eSBiju Das * @crtc: base DRM CRTC 28*11696c5eSBiju Das * @dev: the DU device 29*11696c5eSBiju Das * @clock: the CRTC functional clock 30*11696c5eSBiju Das * @extclock: external pixel dot clock (optional) 31*11696c5eSBiju Das * @mmio_offset: offset of the CRTC registers in the DU MMIO block 32*11696c5eSBiju Das * @index: CRTC hardware index 33*11696c5eSBiju Das * @initialized: whether the CRTC has been initialized and clocks enabled 34*11696c5eSBiju Das * @dsysr: cached value of the DSYSR register 35*11696c5eSBiju Das * @vblank_enable: whether vblank events are enabled on this CRTC 36*11696c5eSBiju Das * @event: event to post when the pending page flip completes 37*11696c5eSBiju Das * @flip_wait: wait queue used to signal page flip completion 38*11696c5eSBiju Das * @vblank_lock: protects vblank_wait and vblank_count 39*11696c5eSBiju Das * @vblank_wait: wait queue used to signal vertical blanking 40*11696c5eSBiju Das * @vblank_count: number of vertical blanking interrupts to wait for 41*11696c5eSBiju Das * @group: CRTC group this CRTC belongs to 42*11696c5eSBiju Das * @cmm: CMM associated with this CRTC 43*11696c5eSBiju Das * @vsp: VSP feeding video to this CRTC 44*11696c5eSBiju Das * @vsp_pipe: index of the VSP pipeline feeding video to this CRTC 45*11696c5eSBiju Das * @writeback: the writeback connector 46*11696c5eSBiju Das */ 47*11696c5eSBiju Das struct rcar_du_crtc { 48*11696c5eSBiju Das struct drm_crtc crtc; 49*11696c5eSBiju Das 50*11696c5eSBiju Das struct rcar_du_device *dev; 51*11696c5eSBiju Das struct clk *clock; 52*11696c5eSBiju Das struct clk *extclock; 53*11696c5eSBiju Das unsigned int mmio_offset; 54*11696c5eSBiju Das unsigned int index; 55*11696c5eSBiju Das bool initialized; 56*11696c5eSBiju Das 57*11696c5eSBiju Das u32 dsysr; 58*11696c5eSBiju Das 59*11696c5eSBiju Das bool vblank_enable; 60*11696c5eSBiju Das struct drm_pending_vblank_event *event; 61*11696c5eSBiju Das wait_queue_head_t flip_wait; 62*11696c5eSBiju Das 63*11696c5eSBiju Das spinlock_t vblank_lock; 64*11696c5eSBiju Das wait_queue_head_t vblank_wait; 65*11696c5eSBiju Das unsigned int vblank_count; 66*11696c5eSBiju Das 67*11696c5eSBiju Das struct rcar_du_group *group; 68*11696c5eSBiju Das struct platform_device *cmm; 69*11696c5eSBiju Das struct rcar_du_vsp *vsp; 70*11696c5eSBiju Das unsigned int vsp_pipe; 71*11696c5eSBiju Das 72*11696c5eSBiju Das const char *const *sources; 73*11696c5eSBiju Das unsigned int sources_count; 74*11696c5eSBiju Das 75*11696c5eSBiju Das struct drm_writeback_connector writeback; 76*11696c5eSBiju Das }; 77*11696c5eSBiju Das 78*11696c5eSBiju Das #define to_rcar_crtc(c) container_of(c, struct rcar_du_crtc, crtc) 79*11696c5eSBiju Das #define wb_to_rcar_crtc(c) container_of(c, struct rcar_du_crtc, writeback) 80*11696c5eSBiju Das 81*11696c5eSBiju Das /** 82*11696c5eSBiju Das * struct rcar_du_crtc_state - Driver-specific CRTC state 83*11696c5eSBiju Das * @state: base DRM CRTC state 84*11696c5eSBiju Das * @crc: CRC computation configuration 85*11696c5eSBiju Das * @outputs: bitmask of the outputs (enum rcar_du_output) driven by this CRTC 86*11696c5eSBiju Das */ 87*11696c5eSBiju Das struct rcar_du_crtc_state { 88*11696c5eSBiju Das struct drm_crtc_state state; 89*11696c5eSBiju Das 90*11696c5eSBiju Das struct vsp1_du_crc_config crc; 91*11696c5eSBiju Das unsigned int outputs; 92*11696c5eSBiju Das }; 93*11696c5eSBiju Das 94*11696c5eSBiju Das #define to_rcar_crtc_state(s) container_of(s, struct rcar_du_crtc_state, state) 95*11696c5eSBiju Das 96*11696c5eSBiju Das int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex, 97*11696c5eSBiju Das unsigned int hwindex); 98*11696c5eSBiju Das 99*11696c5eSBiju Das void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc); 100*11696c5eSBiju Das 101*11696c5eSBiju Das void rcar_du_crtc_dsysr_clr_set(struct rcar_du_crtc *rcrtc, u32 clr, u32 set); 102*11696c5eSBiju Das 103*11696c5eSBiju Das #endif /* __RCAR_DU_CRTC_H__ */ 104