2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <linux/clk.h>
22 #include <linux/platform_device.h>
23 #include <linux/regulator/consumer.h>
27 #include "mdp_common.xml.h"
31 struct mdp_kms_funcs
{
32 struct msm_kms_funcs base
;
33 void (*set_irqmask
)(struct mdp_kms
*mdp_kms
, uint32_t irqmask
,
34 uint32_t old_irqmask
);
40 const struct mdp_kms_funcs
*funcs
;
44 struct list_head irq_list
; /* list of mdp4_irq */
45 uint32_t vblank_mask
; /* irq bits set for userspace vblank */
46 uint32_t cur_irq_mask
; /* current irq mask */
48 #define to_mdp_kms(x) container_of(x, struct mdp_kms, base)
50 static inline void mdp_kms_init(struct mdp_kms
*mdp_kms
,
51 const struct mdp_kms_funcs
*funcs
)
53 mdp_kms
->funcs
= funcs
;
54 INIT_LIST_HEAD(&mdp_kms
->irq_list
);
55 msm_kms_init(&mdp_kms
->base
, &funcs
->base
);
62 /* For transiently registering for different MDP irqs that various parts
63 * of the KMS code need during setup/configuration. These are not
64 * necessarily the same as what drm_vblank_get/put() are requesting, and
65 * the hysteresis in drm_vblank_put() is not necessarily desirable for
66 * internal housekeeping related irq usage.
69 struct list_head node
;
72 void (*irq
)(struct mdp_irq
*irq
, uint32_t irqstatus
);
75 void mdp_dispatch_irqs(struct mdp_kms
*mdp_kms
, uint32_t status
);
76 void mdp_update_vblank_mask(struct mdp_kms
*mdp_kms
, uint32_t mask
, bool enable
);
77 void mdp_irq_wait(struct mdp_kms
*mdp_kms
, uint32_t irqmask
);
78 void mdp_irq_register(struct mdp_kms
*mdp_kms
, struct mdp_irq
*irq
);
79 void mdp_irq_unregister(struct mdp_kms
*mdp_kms
, struct mdp_irq
*irq
);
80 void mdp_irq_update(struct mdp_kms
*mdp_kms
);
83 * pixel format helpers:
87 struct msm_format base
;
88 enum mdp_bpc bpc_r
, bpc_g
, bpc_b
;
89 enum mdp_bpc_alpha bpc_a
;
91 bool alpha_enable
, unpack_tight
;
92 uint8_t cpp
, unpack_count
;
93 enum mdp_fetch_type fetch_type
;
94 enum mdp_chroma_samp_type chroma_sample
;
97 #define to_mdp_format(x) container_of(x, struct mdp_format, base)
98 #define MDP_FORMAT_IS_YUV(mdp_format) ((mdp_format)->is_yuv)
100 uint32_t mdp_get_formats(uint32_t *formats
, uint32_t max_formats
, bool rgb_only
);
101 const struct msm_format
*mdp_get_format(struct msm_kms
*kms
, uint32_t format
);
103 /* MDP capabilities */
104 #define MDP_CAP_SMP BIT(0) /* Shared Memory Pool */
105 #define MDP_CAP_DSC BIT(1) /* VESA Display Stream Compression */
106 #define MDP_CAP_CDM BIT(2) /* Chroma Down Module (HDMI 2.0 YUV) */
108 /* MDP pipe capabilities */
109 #define MDP_PIPE_CAP_HFLIP BIT(0)
110 #define MDP_PIPE_CAP_VFLIP BIT(1)
111 #define MDP_PIPE_CAP_SCALE BIT(2)
112 #define MDP_PIPE_CAP_CSC BIT(3)
113 #define MDP_PIPE_CAP_DECIMATION BIT(4)
114 #define MDP_PIPE_CAP_SW_PIX_EXT BIT(5)
116 static inline bool pipe_supports_yuv(uint32_t pipe_caps
)
118 return (pipe_caps
& MDP_PIPE_CAP_SCALE
) &&
119 (pipe_caps
& MDP_PIPE_CAP_CSC
);
133 uint32_t pre_bias
[3];
134 uint32_t post_bias
[3];
135 uint32_t pre_clamp
[6];
136 uint32_t post_clamp
[6];
139 struct csc_cfg
*mdp_get_default_csc_cfg(enum csc_type
);
141 #endif /* __MDP_KMS_H__ */