blob: 867493df98c507232f5795ab539a4ee9ae3d8b35 [file] [log] [blame]
Rob Clark10a02eb2013-11-30 14:58:23 -05001/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
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.
8 *
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
12 * more details.
13 *
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/>.
16 */
17
18#ifndef __MDP_KMS_H__
19#define __MDP_KMS_H__
20
21#include <linux/clk.h>
22#include <linux/platform_device.h>
23#include <linux/regulator/consumer.h>
24
25#include "msm_drv.h"
Rob Clark9e0efa62013-11-30 17:24:22 -050026#include "msm_kms.h"
Rob Clark10a02eb2013-11-30 14:58:23 -050027#include "mdp_common.xml.h"
28
Rob Clark9e0efa62013-11-30 17:24:22 -050029struct mdp_kms;
30
31struct mdp_kms_funcs {
32 struct msm_kms_funcs base;
33 void (*set_irqmask)(struct mdp_kms *mdp_kms, uint32_t irqmask);
34};
35
36struct mdp_kms {
37 struct msm_kms base;
38
39 const struct mdp_kms_funcs *funcs;
40
41 /* irq handling: */
42 bool in_irq;
43 struct list_head irq_list; /* list of mdp4_irq */
44 uint32_t vblank_mask; /* irq bits set for userspace vblank */
45};
46#define to_mdp_kms(x) container_of(x, struct mdp_kms, base)
47
48static inline void mdp_kms_init(struct mdp_kms *mdp_kms,
49 const struct mdp_kms_funcs *funcs)
50{
51 mdp_kms->funcs = funcs;
52 INIT_LIST_HEAD(&mdp_kms->irq_list);
53 msm_kms_init(&mdp_kms->base, &funcs->base);
54}
55
56/*
57 * irq helpers:
58 */
59
60/* For transiently registering for different MDP irqs that various parts
61 * of the KMS code need during setup/configuration. These are not
62 * necessarily the same as what drm_vblank_get/put() are requesting, and
63 * the hysteresis in drm_vblank_put() is not necessarily desirable for
64 * internal housekeeping related irq usage.
65 */
66struct mdp_irq {
67 struct list_head node;
68 uint32_t irqmask;
69 bool registered;
70 void (*irq)(struct mdp_irq *irq, uint32_t irqstatus);
71};
72
73void mdp_dispatch_irqs(struct mdp_kms *mdp_kms, uint32_t status);
74void mdp_update_vblank_mask(struct mdp_kms *mdp_kms, uint32_t mask, bool enable);
75void mdp_irq_wait(struct mdp_kms *mdp_kms, uint32_t irqmask);
76void mdp_irq_register(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
77void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
Rob Clark8bc1fe92014-12-02 11:50:06 -050078void mdp_irq_update(struct mdp_kms *mdp_kms);
Rob Clark9e0efa62013-11-30 17:24:22 -050079
80/*
81 * pixel format helpers:
82 */
83
Rob Clark10a02eb2013-11-30 14:58:23 -050084struct mdp_format {
85 struct msm_format base;
86 enum mdp_bpc bpc_r, bpc_g, bpc_b;
87 enum mdp_bpc_alpha bpc_a;
88 uint8_t unpack[4];
89 bool alpha_enable, unpack_tight;
90 uint8_t cpp, unpack_count;
Rob Clarkaf6cb4c2015-05-20 10:50:30 -040091 enum mdp_fetch_type fetch_type;
Stephane Viau7ca12712014-12-08 10:48:57 -050092 enum mdp_chroma_samp_type chroma_sample;
Wentao Xuff78a6b2015-07-06 16:35:29 -040093 bool is_yuv;
Rob Clark10a02eb2013-11-30 14:58:23 -050094};
95#define to_mdp_format(x) container_of(x, struct mdp_format, base)
Wentao Xuff78a6b2015-07-06 16:35:29 -040096#define MDP_FORMAT_IS_YUV(mdp_format) ((mdp_format)->is_yuv)
Rob Clark10a02eb2013-11-30 14:58:23 -050097
Stephane Viau7ca12712014-12-08 10:48:57 -050098uint32_t mdp_get_formats(uint32_t *formats, uint32_t max_formats, bool rgb_only);
Rob Clark10a02eb2013-11-30 14:58:23 -050099const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format);
100
jilai wang34984092015-07-08 18:12:40 -0400101/* MDP pipe capabilities */
102#define MDP_PIPE_CAP_HFLIP BIT(0)
103#define MDP_PIPE_CAP_VFLIP BIT(1)
104#define MDP_PIPE_CAP_SCALE BIT(2)
105#define MDP_PIPE_CAP_CSC BIT(3)
106#define MDP_PIPE_CAP_DECIMATION BIT(4)
107
108static inline bool pipe_supports_yuv(uint32_t pipe_caps)
109{
110 return (pipe_caps & MDP_PIPE_CAP_SCALE) &&
111 (pipe_caps & MDP_PIPE_CAP_CSC);
112}
113
Stephane Viau7ca12712014-12-08 10:48:57 -0500114enum csc_type {
115 CSC_RGB2RGB = 0,
116 CSC_YUV2RGB,
117 CSC_RGB2YUV,
118 CSC_YUV2YUV,
119 CSC_MAX
120};
121
122struct csc_cfg {
123 enum csc_type type;
124 uint32_t matrix[9];
125 uint32_t pre_bias[3];
126 uint32_t post_bias[3];
127 uint32_t pre_clamp[6];
128 uint32_t post_clamp[6];
129};
130
131struct csc_cfg *mdp_get_default_csc_cfg(enum csc_type);
132
Rob Clark10a02eb2013-11-30 14:58:23 -0500133#endif /* __MDP_KMS_H__ */