hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/drivers/gpu/drm/bridge/adv7511/adv7533.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 and
6
- * only version 2 as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #include <linux/of_graph.h>
....@@ -108,26 +100,24 @@
108100 regmap_write(adv->regmap_cec, 0x27, 0x0b);
109101 }
110102
111
-void adv7533_mode_set(struct adv7511 *adv, struct drm_display_mode *mode)
103
+enum drm_mode_status adv7533_mode_valid(struct adv7511 *adv,
104
+ const struct drm_display_mode *mode)
112105 {
106
+ unsigned long max_lane_freq;
113107 struct mipi_dsi_device *dsi = adv->dsi;
114
- int lanes, ret;
108
+ u8 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
115109
116
- if (adv->num_dsi_lanes != 4)
117
- return;
110
+ /* Check max clock for either 7533 or 7535 */
111
+ if (mode->clock > (adv->type == ADV7533 ? 80000 : 148500))
112
+ return MODE_CLOCK_HIGH;
118113
119
- if (mode->clock > 80000)
120
- lanes = 4;
121
- else
122
- lanes = 3;
114
+ /* Check max clock for each lane */
115
+ max_lane_freq = (adv->type == ADV7533 ? 800000 : 891000);
123116
124
- if (lanes != dsi->lanes) {
125
- mipi_dsi_detach(dsi);
126
- dsi->lanes = lanes;
127
- ret = mipi_dsi_attach(dsi);
128
- if (ret)
129
- dev_err(&dsi->dev, "failed to change host lanes\n");
130
- }
117
+ if (mode->clock * bpp > max_lane_freq * adv->num_dsi_lanes)
118
+ return MODE_CLOCK_HIGH;
119
+
120
+ return MODE_OK;
131121 }
132122
133123 int adv7533_patch_registers(struct adv7511 *adv)