hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpu/drm/gma500/cdv_intel_lvds.c
....@@ -1,18 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright © 2006-2011 Intel Corporation
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms and conditions of the GNU General Public License,
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * You should have received a copy of the GNU General Public License along with
14
- * this program; if not, write to the Free Software Foundation, Inc.,
15
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
164 *
175 * Authors:
186 * Eric Anholt <eric@anholt.net>
....@@ -20,17 +8,18 @@
208 * Jesse Barnes <jesse.barnes@intel.com>
219 */
2210
23
-#include <linux/i2c.h>
2411 #include <linux/dmi.h>
25
-#include <drm/drmP.h>
12
+#include <linux/i2c.h>
13
+#include <linux/pm_runtime.h>
2614
15
+#include <drm/drm_simple_kms_helper.h>
16
+
17
+#include "cdv_device.h"
2718 #include "intel_bios.h"
19
+#include "power.h"
2820 #include "psb_drv.h"
2921 #include "psb_intel_drv.h"
3022 #include "psb_intel_reg.h"
31
-#include "power.h"
32
-#include <linux/pm_runtime.h>
33
-#include "cdv_device.h"
3423
3524 /**
3625 * LVDS I2C backlight control macros
....@@ -84,89 +73,6 @@
8473
8574 return retval;
8675 }
87
-
88
-#if 0
89
-/*
90
- * Set LVDS backlight level by I2C command
91
- */
92
-static int cdv_lvds_i2c_set_brightness(struct drm_device *dev,
93
- unsigned int level)
94
-{
95
- struct drm_psb_private *dev_priv = dev->dev_private;
96
- struct psb_intel_i2c_chan *lvds_i2c_bus = dev_priv->lvds_i2c_bus;
97
- u8 out_buf[2];
98
- unsigned int blc_i2c_brightness;
99
-
100
- struct i2c_msg msgs[] = {
101
- {
102
- .addr = lvds_i2c_bus->slave_addr,
103
- .flags = 0,
104
- .len = 2,
105
- .buf = out_buf,
106
- }
107
- };
108
-
109
- blc_i2c_brightness = BRIGHTNESS_MASK & ((unsigned int)level *
110
- BRIGHTNESS_MASK /
111
- BRIGHTNESS_MAX_LEVEL);
112
-
113
- if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
114
- blc_i2c_brightness = BRIGHTNESS_MASK - blc_i2c_brightness;
115
-
116
- out_buf[0] = dev_priv->lvds_bl->brightnesscmd;
117
- out_buf[1] = (u8)blc_i2c_brightness;
118
-
119
- if (i2c_transfer(&lvds_i2c_bus->adapter, msgs, 1) == 1)
120
- return 0;
121
-
122
- DRM_ERROR("I2C transfer error\n");
123
- return -1;
124
-}
125
-
126
-
127
-static int cdv_lvds_pwm_set_brightness(struct drm_device *dev, int level)
128
-{
129
- struct drm_psb_private *dev_priv = dev->dev_private;
130
-
131
- u32 max_pwm_blc;
132
- u32 blc_pwm_duty_cycle;
133
-
134
- max_pwm_blc = cdv_intel_lvds_get_max_backlight(dev);
135
-
136
- /*BLC_PWM_CTL Should be initiated while backlight device init*/
137
- BUG_ON((max_pwm_blc & PSB_BLC_MAX_PWM_REG_FREQ) == 0);
138
-
139
- blc_pwm_duty_cycle = level * max_pwm_blc / BRIGHTNESS_MAX_LEVEL;
140
-
141
- if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
142
- blc_pwm_duty_cycle = max_pwm_blc - blc_pwm_duty_cycle;
143
-
144
- blc_pwm_duty_cycle &= PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR;
145
- REG_WRITE(BLC_PWM_CTL,
146
- (max_pwm_blc << PSB_BACKLIGHT_PWM_CTL_SHIFT) |
147
- (blc_pwm_duty_cycle));
148
-
149
- return 0;
150
-}
151
-
152
-/*
153
- * Set LVDS backlight level either by I2C or PWM
154
- */
155
-void cdv_intel_lvds_set_brightness(struct drm_device *dev, int level)
156
-{
157
- struct drm_psb_private *dev_priv = dev->dev_private;
158
-
159
- if (!dev_priv->lvds_bl) {
160
- DRM_ERROR("NO LVDS Backlight Info\n");
161
- return;
162
- }
163
-
164
- if (dev_priv->lvds_bl->type == BLC_I2C_TYPE)
165
- cdv_lvds_i2c_set_brightness(dev, level);
166
- else
167
- cdv_lvds_pwm_set_brightness(dev, level);
168
-}
169
-#endif
17076
17177 /**
17278 * Sets the backlight level.
....@@ -512,16 +418,6 @@
512418 .destroy = cdv_intel_lvds_destroy,
513419 };
514420
515
-
516
-static void cdv_intel_lvds_enc_destroy(struct drm_encoder *encoder)
517
-{
518
- drm_encoder_cleanup(encoder);
519
-}
520
-
521
-static const struct drm_encoder_funcs cdv_intel_lvds_enc_funcs = {
522
- .destroy = cdv_intel_lvds_enc_destroy,
523
-};
524
-
525421 /*
526422 * Enumerate the child dev array parsed from VBT to check whether
527423 * the LVDS is present.
....@@ -629,10 +525,7 @@
629525 &cdv_intel_lvds_connector_funcs,
630526 DRM_MODE_CONNECTOR_LVDS);
631527
632
- drm_encoder_init(dev, encoder,
633
- &cdv_intel_lvds_enc_funcs,
634
- DRM_MODE_ENCODER_LVDS, NULL);
635
-
528
+ drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_LVDS);
636529
637530 gma_connector_attach_encoder(gma_connector, gma_encoder);
638531 gma_encoder->type = INTEL_OUTPUT_LVDS;