1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/list.h>
#include <linux/msm_mdp.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/version.h>
#include <linux/switch.h>
#include "mdss_panel.h"
#include "mdss_wb.h"
#include "mdss.h"
/**
* mdss_wb_check_params - check new panel info params
* @pdata: current panel information
* @new: updates to panel info
*
* Checks if there are any changes that require panel reconfiguration
* in order to be reflected on writeback buffer.
*
* Return negative errno if invalid input, zero if there is no panel reconfig
* needed and non-zero if reconfiguration is needed.
*/
static int mdss_wb_check_params(struct mdss_panel_data *pdata,
struct mdss_panel_info *new)
{
struct mdss_panel_info *old;
if (!pdata || !new) {
pr_err("%s: Invalid input\n", __func__);
return -EINVAL;
}
if (new->xres >= 4096 || new->yres >= 4096) {
pr_err("%s: Invalid resolutions\n", __func__);
return -EINVAL;
}
old = &pdata->panel_info;
if ((old->xres != new->xres) || (old->yres != new->yres))
return 1;
return 0;
}
static int mdss_wb_event_handler(struct mdss_panel_data *pdata,
int event, void *arg)
{
int rc = 0;
switch (event) {
case MDSS_EVENT_CHECK_PARAMS:
rc = mdss_wb_check_params(pdata, (struct mdss_panel_info *)arg);
break;
default:
pr_debug("%s: panel event (%d) not handled\n", __func__, event);
break;
}
return rc;
}
static int mdss_wb_parse_dt(struct platform_device *pdev,
struct mdss_panel_data *pdata)
{
struct device_node *np = pdev->dev.of_node;
u32 res[2], tmp;
int rc;
rc = of_property_read_u32_array(np, "qcom,mdss_pan_res", res, 2);
pdata->panel_info.xres = (!rc ? res[0] : 1280);
pdata->panel_info.yres = (!rc ? res[1] : 720);
rc = of_property_read_u32(np, "qcom,mdss_pan_bpp", &tmp);
pdata->panel_info.bpp = (!rc ? tmp : 24);
return 0;
}
static int mdss_wb_dev_init(struct mdss_wb_ctrl *wb_ctrl)
{
int rc = 0;
if (!wb_ctrl) {
pr_err("%s: no driver data\n", __func__);
return -ENODEV;
}
wb_ctrl->sdev.name = "wfd";
rc = switch_dev_register(&wb_ctrl->sdev);
if (rc) {
pr_err("Failed to setup switch dev for writeback panel");
return rc;
}
return 0;
}
static int mdss_wb_dev_uninit(struct mdss_wb_ctrl *wb_ctrl)
{
if (!wb_ctrl) {
pr_err("%s: no driver data\n", __func__);
return -ENODEV;
}
switch_dev_unregister(&wb_ctrl->sdev);
return 0;
}
static int mdss_wb_probe(struct platform_device *pdev)
{
struct mdss_panel_data *pdata = NULL;
struct mdss_wb_ctrl *wb_ctrl = NULL;
struct mdss_util_intf *util;
int rc = 0;
if (!pdev->dev.of_node)
return -ENODEV;
util = mdss_get_util_intf();
if (util == NULL) {
pr_err("%s: Failed to get mdss utility functions\n", __func__);
return -ENODEV;
}
if (!util->mdp_probe_done) {
pr_err("%s: MDP not probed yet!\n", __func__);
return -EPROBE_DEFER;
}
wb_ctrl = devm_kzalloc(&pdev->dev, sizeof(*wb_ctrl), GFP_KERNEL);
if (!wb_ctrl)
return -ENOMEM;
pdata = &wb_ctrl->pdata;
wb_ctrl->pdev = pdev;
platform_set_drvdata(pdev, wb_ctrl);
rc = !mdss_wb_parse_dt(pdev, pdata);
if (!rc)
goto error_no_mem;
rc = mdss_wb_dev_init(wb_ctrl);
if (rc) {
dev_err(&pdev->dev, "unable to set up device nodes for writeback panel\n");
goto error_no_mem;
}
pdata->panel_info.type = WRITEBACK_PANEL;
pdata->panel_info.clk_rate = 74250000;
pdata->panel_info.pdest = DISPLAY_4;
pdata->panel_info.out_format = MDP_Y_CBCR_H2V2_VENUS;
pdata->event_handler = mdss_wb_event_handler;
pdev->dev.platform_data = pdata;
rc = mdss_register_panel(pdev, pdata);
if (rc) {
dev_err(&pdev->dev, "unable to register writeback panel\n");
goto error_init;
}
return rc;
error_init:
mdss_wb_dev_uninit(wb_ctrl);
error_no_mem:
devm_kfree(&pdev->dev, wb_ctrl);
return rc;
}
static int mdss_wb_remove(struct platform_device *pdev)
{
struct mdss_wb_ctrl *wb_ctrl = platform_get_drvdata(pdev);
if (!wb_ctrl) {
pr_err("%s: no driver data\n", __func__);
return -ENODEV;
}
mdss_wb_dev_uninit(wb_ctrl);
devm_kfree(&wb_ctrl->pdev->dev, wb_ctrl);
return 0;
}
static const struct of_device_id mdss_wb_match[] = {
{ .compatible = "qcom,mdss_wb", },
{ { 0 } }
};
static struct platform_driver mdss_wb_driver = {
.probe = mdss_wb_probe,
.remove = mdss_wb_remove,
.driver = {
.name = "mdss_wb",
.of_match_table = mdss_wb_match,
},
};
static int __init mdss_wb_driver_init(void)
{
int rc = 0;
rc = platform_driver_register(&mdss_wb_driver);
return rc;
}
module_init(mdss_wb_driver_init);
|