Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * R-Car Display Unit CRTCs
0004  *
0005  * Copyright (C) 2013-2015 Renesas Electronics Corporation
0006  *
0007  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
0008  */
0009 
0010 #ifndef __RCAR_DU_CRTC_H__
0011 #define __RCAR_DU_CRTC_H__
0012 
0013 #include <linux/mutex.h>
0014 #include <linux/spinlock.h>
0015 #include <linux/wait.h>
0016 
0017 #include <drm/drm_crtc.h>
0018 #include <drm/drm_writeback.h>
0019 
0020 #include <media/vsp1.h>
0021 
0022 struct rcar_du_group;
0023 struct rcar_du_vsp;
0024 
0025 /**
0026  * struct rcar_du_crtc - the CRTC, representing a DU superposition processor
0027  * @crtc: base DRM CRTC
0028  * @dev: the DU device
0029  * @clock: the CRTC functional clock
0030  * @extclock: external pixel dot clock (optional)
0031  * @mmio_offset: offset of the CRTC registers in the DU MMIO block
0032  * @index: CRTC hardware index
0033  * @initialized: whether the CRTC has been initialized and clocks enabled
0034  * @dsysr: cached value of the DSYSR register
0035  * @vblank_enable: whether vblank events are enabled on this CRTC
0036  * @event: event to post when the pending page flip completes
0037  * @flip_wait: wait queue used to signal page flip completion
0038  * @vblank_lock: protects vblank_wait and vblank_count
0039  * @vblank_wait: wait queue used to signal vertical blanking
0040  * @vblank_count: number of vertical blanking interrupts to wait for
0041  * @group: CRTC group this CRTC belongs to
0042  * @cmm: CMM associated with this CRTC
0043  * @vsp: VSP feeding video to this CRTC
0044  * @vsp_pipe: index of the VSP pipeline feeding video to this CRTC
0045  * @writeback: the writeback connector
0046  */
0047 struct rcar_du_crtc {
0048     struct drm_crtc crtc;
0049 
0050     struct rcar_du_device *dev;
0051     struct clk *clock;
0052     struct clk *extclock;
0053     unsigned int mmio_offset;
0054     unsigned int index;
0055     bool initialized;
0056 
0057     u32 dsysr;
0058 
0059     bool vblank_enable;
0060     struct drm_pending_vblank_event *event;
0061     wait_queue_head_t flip_wait;
0062 
0063     spinlock_t vblank_lock;
0064     wait_queue_head_t vblank_wait;
0065     unsigned int vblank_count;
0066 
0067     struct rcar_du_group *group;
0068     struct platform_device *cmm;
0069     struct rcar_du_vsp *vsp;
0070     unsigned int vsp_pipe;
0071 
0072     const char *const *sources;
0073     unsigned int sources_count;
0074 
0075     struct drm_writeback_connector writeback;
0076 };
0077 
0078 #define to_rcar_crtc(c)     container_of(c, struct rcar_du_crtc, crtc)
0079 #define wb_to_rcar_crtc(c)  container_of(c, struct rcar_du_crtc, writeback)
0080 
0081 /**
0082  * struct rcar_du_crtc_state - Driver-specific CRTC state
0083  * @state: base DRM CRTC state
0084  * @crc: CRC computation configuration
0085  * @outputs: bitmask of the outputs (enum rcar_du_output) driven by this CRTC
0086  */
0087 struct rcar_du_crtc_state {
0088     struct drm_crtc_state state;
0089 
0090     struct vsp1_du_crc_config crc;
0091     unsigned int outputs;
0092 };
0093 
0094 #define to_rcar_crtc_state(s) container_of(s, struct rcar_du_crtc_state, state)
0095 
0096 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex,
0097             unsigned int hwindex);
0098 
0099 void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc);
0100 
0101 void rcar_du_crtc_dsysr_clr_set(struct rcar_du_crtc *rcrtc, u32 clr, u32 set);
0102 
0103 #endif /* __RCAR_DU_CRTC_H__ */