Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'drm/panel/for-3.20-rc1' of git://anongit.freedesktop.org/tegra/linux into drm-next

drm/panel: Changes for v3.20-rc1

This contains the long-awaited drm_bridge series that makes Chromebooks
work for people. I had thought this would've been perfect by now, but
then I go and build test it and the first thing it does is yell about a
recursive dependency. I fixed that up because I was feeling bad for not
getting around to look at this earlier.

Biseds that there is new support for two more panels, a couple of fixup
patches to the Sharp LQ101R1SX01 dual-channel DSI panel driver and a
potential NULL pointer dereference fix.

* tag 'drm/panel/for-3.20-rc1' of git://anongit.freedesktop.org/tegra/linux: (23 commits)
drm/bridge: dw-hdmi: Adapt to bridge API change
drm/sti: fixup for bridge interface
drm/bridge: dw-hdmi: Fix return error path
drm: Check the right variable when setting formats
Documentation: bridge: Add documentation for ps8622 DT properties
Documentation: devicetree: Add vendor prefix for parade
Documentation: drm: bridge: move to video/bridge
drm/bridge: ptn3460: use gpiod interface
drm/bridge: ptn3460: probe connector at the end of bridge attach
drm/bridge: ptn3460: support drm_panel
drm/exynos: dp: support drm_bridge
drm/bridge: ptn3460: Convert to I2C driver model
drm/bridge: make bridge registration independent of drm flow
drm/bridge: do not pass drm_bridge_funcs to drm_bridge_init
drm/bridge: ptn3460: Few trivial cleanups
drm/panel: simple: Add AVIC TM070DDH03 panel support
of: Add vendor prefix for Shanghai AVIC Optoelectronics Co., Ltd.
drm/panel: sharp: lq101r1sx01: Remove unneeded include
drm/panel: sharp: lq101r1sx01: Respect power timings
drm/panel: sharp: lq101r1sx01: Add delay after display on
...

+545 -308
+14 -2
Documentation/devicetree/bindings/drm/bridge/ptn3460.txt Documentation/devicetree/bindings/video/bridge/ptn3460.txt
··· 3 3 Required properties: 4 4 - compatible: "nxp,ptn3460" 5 5 - reg: i2c address of the bridge 6 - - powerdown-gpio: OF device-tree gpio specification 7 - - reset-gpio: OF device-tree gpio specification 6 + - powerdown-gpio: OF device-tree gpio specification for PD_N pin. 7 + - reset-gpio: OF device-tree gpio specification for RST_N pin. 8 8 - edid-emulation: The EDID emulation entry to use 9 9 +-------+------------+------------------+ 10 10 | Value | Resolution | Description | ··· 17 17 | 6 | 1600x900 | ChiMei M215HGE | 18 18 +-------+------------+------------------+ 19 19 20 + - video interfaces: Device node can contain video interface port 21 + nodes for panel according to [1]. 22 + 23 + [1]: Documentation/devicetree/bindings/media/video-interfaces.txt 24 + 20 25 Example: 21 26 lvds-bridge@20 { 22 27 compatible = "nxp,ptn3460"; ··· 29 24 powerdown-gpio = <&gpy2 5 1 0 0>; 30 25 reset-gpio = <&gpx1 5 1 0 0>; 31 26 edid-emulation = <5>; 27 + ports { 28 + port@0 { 29 + bridge_out: endpoint { 30 + remote-endpoint = <&panel_in>; 31 + }; 32 + }; 33 + }; 32 34 };
+7
Documentation/devicetree/bindings/panel/avic,tm070ddh03.txt
··· 1 + Shanghai AVIC Optoelectronics 7" 1024x600 color TFT-LCD panel 2 + 3 + Required properties: 4 + - compatible: should be "avic,tm070ddh03" 5 + 6 + This binding is compatible with the simple-panel binding, which is specified 7 + in simple-panel.txt in this directory.
+7
Documentation/devicetree/bindings/panel/giantplus,gpg482739qs5.txt
··· 1 + GiantPlus GPG48273QS5 4.3" (480x272) WQVGA TFT LCD panel 2 + 3 + Required properties: 4 + - compatible: should be "giantplus,gpg48273qs5" 5 + 6 + This binding is compatible with the simple-panel binding, which is specified 7 + in simple-panel.txt in this directory.
+3
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 23 23 atmel Atmel Corporation 24 24 auo AU Optronics Corporation 25 25 avago Avago Technologies 26 + avic Shanghai AVIC Optoelectronics Co., Ltd. 26 27 bosch Bosch Sensortec GmbH 27 28 brcm Broadcom Corporation 28 29 buffalo Buffalo, Inc. ··· 63 62 GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc. 64 63 gef GE Fanuc Intelligent Platforms Embedded Systems, Inc. 65 64 geniatech Geniatech, Inc. 65 + giantplus Giantplus Technology Co., Ltd. 66 66 globalscale Globalscale Technologies, Inc. 67 67 gmt Global Mixed-mode Technology, Inc. 68 68 google Google, Inc. ··· 121 119 onnn ON Semiconductor Corp. 122 120 opencores OpenCores.org 123 121 panasonic Panasonic Corporation 122 + parade Parade Technologies Inc. 124 123 pericom Pericom Technology Inc. 125 124 phytec PHYTEC Messtechnik GmbH 126 125 picochip Picochip Ltd
+31
Documentation/devicetree/bindings/video/bridge/ps8622.txt
··· 1 + ps8622-bridge bindings 2 + 3 + Required properties: 4 + - compatible: "parade,ps8622" or "parade,ps8625" 5 + - reg: first i2c address of the bridge 6 + - sleep-gpios: OF device-tree gpio specification for PD_ pin. 7 + - reset-gpios: OF device-tree gpio specification for RST_ pin. 8 + 9 + Optional properties: 10 + - lane-count: number of DP lanes to use 11 + - use-external-pwm: backlight will be controlled by an external PWM 12 + - video interfaces: Device node can contain video interface port 13 + nodes for panel according to [1]. 14 + 15 + [1]: Documentation/devicetree/bindings/media/video-interfaces.txt 16 + 17 + Example: 18 + lvds-bridge@48 { 19 + compatible = "parade,ps8622"; 20 + reg = <0x48>; 21 + sleep-gpios = <&gpc3 6 1 0 0>; 22 + reset-gpios = <&gpc3 1 1 0 0>; 23 + lane-count = <1>; 24 + ports { 25 + port@0 { 26 + bridge_out: endpoint { 27 + remote-endpoint = <&panel_in>; 28 + }; 29 + }; 30 + }; 31 + };
+12
Documentation/devicetree/bindings/video/exynos_dp.txt
··· 66 66 Hotplug detect GPIO. 67 67 Indicates which GPIO should be used for hotplug 68 68 detection 69 + -video interfaces: Device node can contain video interface port 70 + nodes according to [1]. 71 + 72 + [1]: Documentation/devicetree/bindings/media/video-interfaces.txt 69 73 70 74 Example: 71 75 ··· 107 103 vback-porch = <10>; 108 104 vfront-porch = <12>; 109 105 vsync-len = <6>; 106 + }; 107 + }; 108 + 109 + ports { 110 + port@0 { 111 + dp_out: endpoint { 112 + remote-endpoint = <&bridge_in>; 113 + }; 110 114 }; 111 115 }; 112 116 };
+1 -1
drivers/gpu/drm/Makefile
··· 14 14 drm_info.o drm_debugfs.o drm_encoder_slave.o \ 15 15 drm_trace_points.o drm_global.o drm_prime.o \ 16 16 drm_rect.o drm_vma_manager.o drm_flip_work.o \ 17 - drm_modeset_lock.o drm_atomic.o 17 + drm_modeset_lock.o drm_atomic.o drm_bridge.o 18 18 19 19 drm-$(CONFIG_COMPAT) += drm_ioc32.o 20 20 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
+9 -6
drivers/gpu/drm/bridge/Kconfig
··· 1 - config DRM_PTN3460 2 - tristate "PTN3460 DP/LVDS bridge" 3 - depends on DRM 4 - select DRM_KMS_HELPER 5 - ---help--- 6 - 7 1 config DRM_DW_HDMI 8 2 tristate 9 3 depends on DRM 10 4 select DRM_KMS_HELPER 5 + 6 + config DRM_PTN3460 7 + tristate "PTN3460 DP/LVDS bridge" 8 + depends on DRM 9 + depends on OF 10 + select DRM_KMS_HELPER 11 + select DRM_PANEL 12 + ---help--- 13 + ptn3460 eDP-LVDS bridge chip driver.
+3 -10
drivers/gpu/drm/bridge/dw_hdmi.c
··· 1373 1373 dw_hdmi_poweron(hdmi); 1374 1374 } 1375 1375 1376 - static void dw_hdmi_bridge_destroy(struct drm_bridge *bridge) 1377 - { 1378 - drm_bridge_cleanup(bridge); 1379 - kfree(bridge); 1380 - } 1381 - 1382 1376 static void dw_hdmi_bridge_nop(struct drm_bridge *bridge) 1383 1377 { 1384 1378 /* do nothing */ ··· 1462 1468 .post_disable = dw_hdmi_bridge_nop, 1463 1469 .mode_set = dw_hdmi_bridge_mode_set, 1464 1470 .mode_fixup = dw_hdmi_bridge_mode_fixup, 1465 - .destroy = dw_hdmi_bridge_destroy, 1466 1471 }; 1467 1472 1468 1473 static irqreturn_t dw_hdmi_hardirq(int irq, void *dev_id) ··· 1524 1531 1525 1532 hdmi->bridge = bridge; 1526 1533 bridge->driver_private = hdmi; 1527 - 1528 - ret = drm_bridge_init(drm, bridge, &dw_hdmi_bridge_funcs); 1534 + bridge->funcs = &dw_hdmi_bridge_funcs; 1535 + ret = drm_bridge_attach(drm, bridge); 1529 1536 if (ret) { 1530 1537 DRM_ERROR("Failed to initialize bridge with drm\n"); 1531 1538 return -EINVAL; ··· 1642 1649 dw_hdmi_irq, IRQF_SHARED, 1643 1650 dev_name(dev), hdmi); 1644 1651 if (ret) 1645 - return ret; 1652 + goto err_iahb; 1646 1653 1647 1654 /* 1648 1655 * To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator
+205 -131
drivers/gpu/drm/bridge/ptn3460.c
··· 13 13 * GNU General Public License for more details. 14 14 */ 15 15 16 + #include <linux/delay.h> 17 + #include <linux/gpio.h> 18 + #include <linux/i2c.h> 16 19 #include <linux/module.h> 17 20 #include <linux/of.h> 18 21 #include <linux/of_gpio.h> 19 - #include <linux/i2c.h> 20 - #include <linux/gpio.h> 21 - #include <linux/delay.h> 22 + #include <linux/of_graph.h> 22 23 23 - #include "drmP.h" 24 - #include "drm_edid.h" 25 - #include "drm_crtc.h" 26 - #include "drm_crtc_helper.h" 24 + #include <drm/drm_panel.h> 27 25 28 26 #include "bridge/ptn3460.h" 27 + 28 + #include "drm_crtc.h" 29 + #include "drm_crtc_helper.h" 30 + #include "drm_edid.h" 31 + #include "drmP.h" 29 32 30 33 #define PTN3460_EDID_ADDR 0x0 31 34 #define PTN3460_EDID_EMULATION_ADDR 0x84 ··· 39 36 struct ptn3460_bridge { 40 37 struct drm_connector connector; 41 38 struct i2c_client *client; 42 - struct drm_encoder *encoder; 43 - struct drm_bridge *bridge; 39 + struct drm_bridge bridge; 44 40 struct edid *edid; 45 - int gpio_pd_n; 46 - int gpio_rst_n; 41 + struct drm_panel *panel; 42 + struct gpio_desc *gpio_pd_n; 43 + struct gpio_desc *gpio_rst_n; 47 44 u32 edid_emulation; 48 45 bool enabled; 49 46 }; 47 + 48 + static inline struct ptn3460_bridge * 49 + bridge_to_ptn3460(struct drm_bridge *bridge) 50 + { 51 + return container_of(bridge, struct ptn3460_bridge, bridge); 52 + } 53 + 54 + static inline struct ptn3460_bridge * 55 + connector_to_ptn3460(struct drm_connector *connector) 56 + { 57 + return container_of(connector, struct ptn3460_bridge, connector); 58 + } 50 59 51 60 static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr, 52 61 u8 *buf, int len) ··· 107 92 ret = ptn3460_write_byte(ptn_bridge, PTN3460_EDID_SRAM_LOAD_ADDR, 108 93 ptn_bridge->edid_emulation); 109 94 if (ret) { 110 - DRM_ERROR("Failed to transfer edid to sram, ret=%d\n", ret); 95 + DRM_ERROR("Failed to transfer EDID to sram, ret=%d\n", ret); 111 96 return ret; 112 97 } 113 98 ··· 117 102 118 103 ret = ptn3460_write_byte(ptn_bridge, PTN3460_EDID_EMULATION_ADDR, val); 119 104 if (ret) { 120 - DRM_ERROR("Failed to write edid value, ret=%d\n", ret); 105 + DRM_ERROR("Failed to write EDID value, ret=%d\n", ret); 121 106 return ret; 122 107 } 123 108 ··· 126 111 127 112 static void ptn3460_pre_enable(struct drm_bridge *bridge) 128 113 { 129 - struct ptn3460_bridge *ptn_bridge = bridge->driver_private; 114 + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); 130 115 int ret; 131 116 132 117 if (ptn_bridge->enabled) 133 118 return; 134 119 135 - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) 136 - gpio_set_value(ptn_bridge->gpio_pd_n, 1); 120 + gpiod_set_value(ptn_bridge->gpio_pd_n, 1); 137 121 138 - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) { 139 - gpio_set_value(ptn_bridge->gpio_rst_n, 0); 140 - udelay(10); 141 - gpio_set_value(ptn_bridge->gpio_rst_n, 1); 122 + gpiod_set_value(ptn_bridge->gpio_rst_n, 0); 123 + usleep_range(10, 20); 124 + gpiod_set_value(ptn_bridge->gpio_rst_n, 1); 125 + 126 + if (drm_panel_prepare(ptn_bridge->panel)) { 127 + DRM_ERROR("failed to prepare panel\n"); 128 + return; 142 129 } 143 130 144 131 /* ··· 152 135 153 136 ret = ptn3460_select_edid(ptn_bridge); 154 137 if (ret) 155 - DRM_ERROR("Select edid failed ret=%d\n", ret); 138 + DRM_ERROR("Select EDID failed ret=%d\n", ret); 156 139 157 140 ptn_bridge->enabled = true; 158 141 } 159 142 160 143 static void ptn3460_enable(struct drm_bridge *bridge) 161 144 { 145 + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); 146 + 147 + if (drm_panel_enable(ptn_bridge->panel)) { 148 + DRM_ERROR("failed to enable panel\n"); 149 + return; 150 + } 162 151 } 163 152 164 153 static void ptn3460_disable(struct drm_bridge *bridge) 165 154 { 166 - struct ptn3460_bridge *ptn_bridge = bridge->driver_private; 155 + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); 167 156 168 157 if (!ptn_bridge->enabled) 169 158 return; 170 159 171 160 ptn_bridge->enabled = false; 172 161 173 - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) 174 - gpio_set_value(ptn_bridge->gpio_rst_n, 1); 162 + if (drm_panel_disable(ptn_bridge->panel)) { 163 + DRM_ERROR("failed to disable panel\n"); 164 + return; 165 + } 175 166 176 - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) 177 - gpio_set_value(ptn_bridge->gpio_pd_n, 0); 167 + gpiod_set_value(ptn_bridge->gpio_rst_n, 1); 168 + gpiod_set_value(ptn_bridge->gpio_pd_n, 0); 178 169 } 179 170 180 171 static void ptn3460_post_disable(struct drm_bridge *bridge) 181 172 { 173 + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); 174 + 175 + if (drm_panel_unprepare(ptn_bridge->panel)) { 176 + DRM_ERROR("failed to unprepare panel\n"); 177 + return; 178 + } 182 179 } 183 180 184 - void ptn3460_bridge_destroy(struct drm_bridge *bridge) 185 - { 186 - struct ptn3460_bridge *ptn_bridge = bridge->driver_private; 187 - 188 - drm_bridge_cleanup(bridge); 189 - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) 190 - gpio_free(ptn_bridge->gpio_pd_n); 191 - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) 192 - gpio_free(ptn_bridge->gpio_rst_n); 193 - /* Nothing else to free, we've got devm allocated memory */ 194 - } 195 - 196 - struct drm_bridge_funcs ptn3460_bridge_funcs = { 197 - .pre_enable = ptn3460_pre_enable, 198 - .enable = ptn3460_enable, 199 - .disable = ptn3460_disable, 200 - .post_disable = ptn3460_post_disable, 201 - .destroy = ptn3460_bridge_destroy, 202 - }; 203 - 204 - int ptn3460_get_modes(struct drm_connector *connector) 181 + static int ptn3460_get_modes(struct drm_connector *connector) 205 182 { 206 183 struct ptn3460_bridge *ptn_bridge; 207 184 u8 *edid; 208 - int ret, num_modes; 185 + int ret, num_modes = 0; 209 186 bool power_off; 210 187 211 - ptn_bridge = container_of(connector, struct ptn3460_bridge, connector); 188 + ptn_bridge = connector_to_ptn3460(connector); 212 189 213 190 if (ptn_bridge->edid) 214 191 return drm_add_edid_modes(connector, ptn_bridge->edid); 215 192 216 193 power_off = !ptn_bridge->enabled; 217 - ptn3460_pre_enable(ptn_bridge->bridge); 194 + ptn3460_pre_enable(&ptn_bridge->bridge); 218 195 219 196 edid = kmalloc(EDID_LENGTH, GFP_KERNEL); 220 197 if (!edid) { 221 - DRM_ERROR("Failed to allocate edid\n"); 198 + DRM_ERROR("Failed to allocate EDID\n"); 222 199 return 0; 223 200 } 224 201 ··· 220 209 EDID_LENGTH); 221 210 if (ret) { 222 211 kfree(edid); 223 - num_modes = 0; 224 212 goto out; 225 213 } 226 214 ··· 230 220 231 221 out: 232 222 if (power_off) 233 - ptn3460_disable(ptn_bridge->bridge); 223 + ptn3460_disable(&ptn_bridge->bridge); 234 224 235 225 return num_modes; 236 226 } 237 227 238 - struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector) 228 + static struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector) 239 229 { 240 - struct ptn3460_bridge *ptn_bridge; 230 + struct ptn3460_bridge *ptn_bridge = connector_to_ptn3460(connector); 241 231 242 - ptn_bridge = container_of(connector, struct ptn3460_bridge, connector); 243 - 244 - return ptn_bridge->encoder; 232 + return ptn_bridge->bridge.encoder; 245 233 } 246 234 247 - struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = { 235 + static struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = { 248 236 .get_modes = ptn3460_get_modes, 249 237 .best_encoder = ptn3460_best_encoder, 250 238 }; 251 239 252 - enum drm_connector_status ptn3460_detect(struct drm_connector *connector, 240 + static enum drm_connector_status ptn3460_detect(struct drm_connector *connector, 253 241 bool force) 254 242 { 255 243 return connector_status_connected; 256 244 } 257 245 258 - void ptn3460_connector_destroy(struct drm_connector *connector) 246 + static void ptn3460_connector_destroy(struct drm_connector *connector) 259 247 { 260 248 drm_connector_cleanup(connector); 261 249 } 262 250 263 - struct drm_connector_funcs ptn3460_connector_funcs = { 251 + static struct drm_connector_funcs ptn3460_connector_funcs = { 264 252 .dpms = drm_helper_connector_dpms, 265 253 .fill_modes = drm_helper_probe_single_connector_modes, 266 254 .detect = ptn3460_detect, 267 255 .destroy = ptn3460_connector_destroy, 268 256 }; 269 257 270 - int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder, 271 - struct i2c_client *client, struct device_node *node) 258 + int ptn3460_bridge_attach(struct drm_bridge *bridge) 272 259 { 260 + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); 273 261 int ret; 274 - struct drm_bridge *bridge; 275 - struct ptn3460_bridge *ptn_bridge; 276 262 277 - bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL); 278 - if (!bridge) { 279 - DRM_ERROR("Failed to allocate drm bridge\n"); 280 - return -ENOMEM; 263 + if (!bridge->encoder) { 264 + DRM_ERROR("Parent encoder object not found"); 265 + return -ENODEV; 281 266 } 282 267 283 - ptn_bridge = devm_kzalloc(dev->dev, sizeof(*ptn_bridge), GFP_KERNEL); 284 - if (!ptn_bridge) { 285 - DRM_ERROR("Failed to allocate ptn bridge\n"); 286 - return -ENOMEM; 287 - } 288 - 289 - ptn_bridge->client = client; 290 - ptn_bridge->encoder = encoder; 291 - ptn_bridge->bridge = bridge; 292 - ptn_bridge->gpio_pd_n = of_get_named_gpio(node, "powerdown-gpio", 0); 293 - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) { 294 - ret = gpio_request_one(ptn_bridge->gpio_pd_n, 295 - GPIOF_OUT_INIT_HIGH, "PTN3460_PD_N"); 296 - if (ret) { 297 - DRM_ERROR("Request powerdown-gpio failed (%d)\n", ret); 298 - return ret; 299 - } 300 - } 301 - 302 - ptn_bridge->gpio_rst_n = of_get_named_gpio(node, "reset-gpio", 0); 303 - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) { 304 - /* 305 - * Request the reset pin low to avoid the bridge being 306 - * initialized prematurely 307 - */ 308 - ret = gpio_request_one(ptn_bridge->gpio_rst_n, 309 - GPIOF_OUT_INIT_LOW, "PTN3460_RST_N"); 310 - if (ret) { 311 - DRM_ERROR("Request reset-gpio failed (%d)\n", ret); 312 - gpio_free(ptn_bridge->gpio_pd_n); 313 - return ret; 314 - } 315 - } 316 - 317 - ret = of_property_read_u32(node, "edid-emulation", 318 - &ptn_bridge->edid_emulation); 319 - if (ret) { 320 - DRM_ERROR("Can't read edid emulation value\n"); 321 - goto err; 322 - } 323 - 324 - ret = drm_bridge_init(dev, bridge, &ptn3460_bridge_funcs); 325 - if (ret) { 326 - DRM_ERROR("Failed to initialize bridge with drm\n"); 327 - goto err; 328 - } 329 - 330 - bridge->driver_private = ptn_bridge; 331 - encoder->bridge = bridge; 332 - 333 - ret = drm_connector_init(dev, &ptn_bridge->connector, 268 + ptn_bridge->connector.polled = DRM_CONNECTOR_POLL_HPD; 269 + ret = drm_connector_init(bridge->dev, &ptn_bridge->connector, 334 270 &ptn3460_connector_funcs, DRM_MODE_CONNECTOR_LVDS); 335 271 if (ret) { 336 272 DRM_ERROR("Failed to initialize connector with drm\n"); 337 - goto err; 273 + return ret; 338 274 } 339 275 drm_connector_helper_add(&ptn_bridge->connector, 340 - &ptn3460_connector_helper_funcs); 276 + &ptn3460_connector_helper_funcs); 341 277 drm_connector_register(&ptn_bridge->connector); 342 - drm_mode_connector_attach_encoder(&ptn_bridge->connector, encoder); 278 + drm_mode_connector_attach_encoder(&ptn_bridge->connector, 279 + bridge->encoder); 343 280 344 - return 0; 281 + if (ptn_bridge->panel) 282 + drm_panel_attach(ptn_bridge->panel, &ptn_bridge->connector); 345 283 346 - err: 347 - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) 348 - gpio_free(ptn_bridge->gpio_pd_n); 349 - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) 350 - gpio_free(ptn_bridge->gpio_rst_n); 284 + drm_helper_hpd_irq_event(ptn_bridge->connector.dev); 285 + 351 286 return ret; 352 287 } 353 - EXPORT_SYMBOL(ptn3460_init); 288 + 289 + static struct drm_bridge_funcs ptn3460_bridge_funcs = { 290 + .pre_enable = ptn3460_pre_enable, 291 + .enable = ptn3460_enable, 292 + .disable = ptn3460_disable, 293 + .post_disable = ptn3460_post_disable, 294 + .attach = ptn3460_bridge_attach, 295 + }; 296 + 297 + static int ptn3460_probe(struct i2c_client *client, 298 + const struct i2c_device_id *id) 299 + { 300 + struct device *dev = &client->dev; 301 + struct ptn3460_bridge *ptn_bridge; 302 + struct device_node *endpoint, *panel_node; 303 + int ret; 304 + 305 + ptn_bridge = devm_kzalloc(dev, sizeof(*ptn_bridge), GFP_KERNEL); 306 + if (!ptn_bridge) { 307 + return -ENOMEM; 308 + } 309 + 310 + endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); 311 + if (endpoint) { 312 + panel_node = of_graph_get_remote_port_parent(endpoint); 313 + if (panel_node) { 314 + ptn_bridge->panel = of_drm_find_panel(panel_node); 315 + of_node_put(panel_node); 316 + if (!ptn_bridge->panel) 317 + return -EPROBE_DEFER; 318 + } 319 + } 320 + 321 + ptn_bridge->client = client; 322 + 323 + ptn_bridge->gpio_pd_n = devm_gpiod_get(&client->dev, "powerdown"); 324 + if (IS_ERR(ptn_bridge->gpio_pd_n)) { 325 + ret = PTR_ERR(ptn_bridge->gpio_pd_n); 326 + dev_err(dev, "cannot get gpio_pd_n %d\n", ret); 327 + return ret; 328 + } 329 + 330 + ret = gpiod_direction_output(ptn_bridge->gpio_pd_n, 1); 331 + if (ret) { 332 + DRM_ERROR("cannot configure gpio_pd_n\n"); 333 + return ret; 334 + } 335 + 336 + ptn_bridge->gpio_rst_n = devm_gpiod_get(&client->dev, "reset"); 337 + if (IS_ERR(ptn_bridge->gpio_rst_n)) { 338 + ret = PTR_ERR(ptn_bridge->gpio_rst_n); 339 + DRM_ERROR("cannot get gpio_rst_n %d\n", ret); 340 + return ret; 341 + } 342 + /* 343 + * Request the reset pin low to avoid the bridge being 344 + * initialized prematurely 345 + */ 346 + ret = gpiod_direction_output(ptn_bridge->gpio_rst_n, 0); 347 + if (ret) { 348 + DRM_ERROR("cannot configure gpio_rst_n\n"); 349 + return ret; 350 + } 351 + 352 + ret = of_property_read_u32(dev->of_node, "edid-emulation", 353 + &ptn_bridge->edid_emulation); 354 + if (ret) { 355 + dev_err(dev, "Can't read EDID emulation value\n"); 356 + return ret; 357 + } 358 + 359 + ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs; 360 + ptn_bridge->bridge.of_node = dev->of_node; 361 + ret = drm_bridge_add(&ptn_bridge->bridge); 362 + if (ret) { 363 + DRM_ERROR("Failed to add bridge\n"); 364 + return ret; 365 + } 366 + 367 + i2c_set_clientdata(client, ptn_bridge); 368 + 369 + return 0; 370 + } 371 + 372 + static int ptn3460_remove(struct i2c_client *client) 373 + { 374 + struct ptn3460_bridge *ptn_bridge = i2c_get_clientdata(client); 375 + 376 + drm_bridge_remove(&ptn_bridge->bridge); 377 + 378 + return 0; 379 + } 380 + 381 + static const struct i2c_device_id ptn3460_i2c_table[] = { 382 + {"nxp,ptn3460", 0}, 383 + {}, 384 + }; 385 + MODULE_DEVICE_TABLE(i2c, ptn3460_i2c_table); 386 + 387 + static const struct of_device_id ptn3460_match[] = { 388 + { .compatible = "nxp,ptn3460" }, 389 + {}, 390 + }; 391 + MODULE_DEVICE_TABLE(of, ptn3460_match); 392 + 393 + static struct i2c_driver ptn3460_driver = { 394 + .id_table = ptn3460_i2c_table, 395 + .probe = ptn3460_probe, 396 + .remove = ptn3460_remove, 397 + .driver = { 398 + .name = "nxp,ptn3460", 399 + .owner = THIS_MODULE, 400 + .of_match_table = ptn3460_match, 401 + }, 402 + }; 403 + module_i2c_driver(ptn3460_driver); 404 + 405 + MODULE_AUTHOR("Sean Paul <seanpaul@chromium.org>"); 406 + MODULE_DESCRIPTION("NXP ptn3460 eDP-LVDS converter driver"); 407 + MODULE_LICENSE("GPL v2");
+91
drivers/gpu/drm/drm_bridge.c
··· 1 + /* 2 + * Copyright (c) 2014 Samsung Electronics Co., Ltd 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sub license, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice (including the 12 + * next paragraph) shall be included in all copies or substantial portions 13 + * of the Software. 14 + * 15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 + * DEALINGS IN THE SOFTWARE. 22 + */ 23 + 24 + #include <linux/err.h> 25 + #include <linux/module.h> 26 + 27 + #include <drm/drm_crtc.h> 28 + 29 + #include "drm/drmP.h" 30 + 31 + static DEFINE_MUTEX(bridge_lock); 32 + static LIST_HEAD(bridge_list); 33 + 34 + int drm_bridge_add(struct drm_bridge *bridge) 35 + { 36 + mutex_lock(&bridge_lock); 37 + list_add_tail(&bridge->list, &bridge_list); 38 + mutex_unlock(&bridge_lock); 39 + 40 + return 0; 41 + } 42 + EXPORT_SYMBOL(drm_bridge_add); 43 + 44 + void drm_bridge_remove(struct drm_bridge *bridge) 45 + { 46 + mutex_lock(&bridge_lock); 47 + list_del_init(&bridge->list); 48 + mutex_unlock(&bridge_lock); 49 + } 50 + EXPORT_SYMBOL(drm_bridge_remove); 51 + 52 + extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge) 53 + { 54 + if (!dev || !bridge) 55 + return -EINVAL; 56 + 57 + if (bridge->dev) 58 + return -EBUSY; 59 + 60 + bridge->dev = dev; 61 + 62 + if (bridge->funcs->attach) 63 + return bridge->funcs->attach(bridge); 64 + 65 + return 0; 66 + } 67 + EXPORT_SYMBOL(drm_bridge_attach); 68 + 69 + #ifdef CONFIG_OF 70 + struct drm_bridge *of_drm_find_bridge(struct device_node *np) 71 + { 72 + struct drm_bridge *bridge; 73 + 74 + mutex_lock(&bridge_lock); 75 + 76 + list_for_each_entry(bridge, &bridge_list, list) { 77 + if (bridge->of_node == np) { 78 + mutex_unlock(&bridge_lock); 79 + return bridge; 80 + } 81 + } 82 + 83 + mutex_unlock(&bridge_lock); 84 + return NULL; 85 + } 86 + EXPORT_SYMBOL(of_drm_find_bridge); 87 + #endif 88 + 89 + MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>"); 90 + MODULE_DESCRIPTION("DRM bridge infrastructure"); 91 + MODULE_LICENSE("GPL and additional rights");
+1 -71
drivers/gpu/drm/drm_crtc.c
··· 787 787 if (formats && num_formats) { 788 788 fmts = kmemdup(formats, sizeof(*formats) * num_formats, 789 789 GFP_KERNEL); 790 - if (!formats) 790 + if (!fmts) 791 791 return -ENOMEM; 792 792 } 793 793 ··· 1064 1064 1065 1065 } 1066 1066 EXPORT_SYMBOL(drm_connector_unplug_all); 1067 - 1068 - /** 1069 - * drm_bridge_init - initialize a drm transcoder/bridge 1070 - * @dev: drm device 1071 - * @bridge: transcoder/bridge to set up 1072 - * @funcs: bridge function table 1073 - * 1074 - * Initialises a preallocated bridge. Bridges should be 1075 - * subclassed as part of driver connector objects. 1076 - * 1077 - * Returns: 1078 - * Zero on success, error code on failure. 1079 - */ 1080 - int drm_bridge_init(struct drm_device *dev, struct drm_bridge *bridge, 1081 - const struct drm_bridge_funcs *funcs) 1082 - { 1083 - int ret; 1084 - 1085 - drm_modeset_lock_all(dev); 1086 - 1087 - ret = drm_mode_object_get(dev, &bridge->base, DRM_MODE_OBJECT_BRIDGE); 1088 - if (ret) 1089 - goto out; 1090 - 1091 - bridge->dev = dev; 1092 - bridge->funcs = funcs; 1093 - 1094 - list_add_tail(&bridge->head, &dev->mode_config.bridge_list); 1095 - dev->mode_config.num_bridge++; 1096 - 1097 - out: 1098 - drm_modeset_unlock_all(dev); 1099 - return ret; 1100 - } 1101 - EXPORT_SYMBOL(drm_bridge_init); 1102 - 1103 - /** 1104 - * drm_bridge_cleanup - cleans up an initialised bridge 1105 - * @bridge: bridge to cleanup 1106 - * 1107 - * Cleans up the bridge but doesn't free the object. 1108 - */ 1109 - void drm_bridge_cleanup(struct drm_bridge *bridge) 1110 - { 1111 - struct drm_device *dev = bridge->dev; 1112 - 1113 - drm_modeset_lock_all(dev); 1114 - drm_mode_object_put(dev, &bridge->base); 1115 - list_del(&bridge->head); 1116 - dev->mode_config.num_bridge--; 1117 - drm_modeset_unlock_all(dev); 1118 - 1119 - memset(bridge, 0, sizeof(*bridge)); 1120 - } 1121 - EXPORT_SYMBOL(drm_bridge_cleanup); 1122 1067 1123 1068 /** 1124 1069 * drm_encoder_init - Init a preallocated encoder ··· 1660 1715 total_objects += dev->mode_config.num_crtc; 1661 1716 total_objects += dev->mode_config.num_connector; 1662 1717 total_objects += dev->mode_config.num_encoder; 1663 - total_objects += dev->mode_config.num_bridge; 1664 1718 1665 1719 group->id_list = kcalloc(total_objects, sizeof(uint32_t), GFP_KERNEL); 1666 1720 if (!group->id_list) ··· 1668 1724 group->num_crtcs = 0; 1669 1725 group->num_connectors = 0; 1670 1726 group->num_encoders = 0; 1671 - group->num_bridges = 0; 1672 1727 return 0; 1673 1728 } 1674 1729 ··· 1687 1744 struct drm_crtc *crtc; 1688 1745 struct drm_encoder *encoder; 1689 1746 struct drm_connector *connector; 1690 - struct drm_bridge *bridge; 1691 1747 int ret; 1692 1748 1693 1749 ret = drm_mode_group_init(dev, group); ··· 1703 1761 list_for_each_entry(connector, &dev->mode_config.connector_list, head) 1704 1762 group->id_list[group->num_crtcs + group->num_encoders + 1705 1763 group->num_connectors++] = connector->base.id; 1706 - 1707 - list_for_each_entry(bridge, &dev->mode_config.bridge_list, head) 1708 - group->id_list[group->num_crtcs + group->num_encoders + 1709 - group->num_connectors + group->num_bridges++] = 1710 - bridge->base.id; 1711 1764 1712 1765 return 0; 1713 1766 } ··· 5380 5443 INIT_LIST_HEAD(&dev->mode_config.fb_list); 5381 5444 INIT_LIST_HEAD(&dev->mode_config.crtc_list); 5382 5445 INIT_LIST_HEAD(&dev->mode_config.connector_list); 5383 - INIT_LIST_HEAD(&dev->mode_config.bridge_list); 5384 5446 INIT_LIST_HEAD(&dev->mode_config.encoder_list); 5385 5447 INIT_LIST_HEAD(&dev->mode_config.property_list); 5386 5448 INIT_LIST_HEAD(&dev->mode_config.property_blob_list); ··· 5419 5483 struct drm_connector *connector, *ot; 5420 5484 struct drm_crtc *crtc, *ct; 5421 5485 struct drm_encoder *encoder, *enct; 5422 - struct drm_bridge *bridge, *brt; 5423 5486 struct drm_framebuffer *fb, *fbt; 5424 5487 struct drm_property *property, *pt; 5425 5488 struct drm_property_blob *blob, *bt; ··· 5427 5492 list_for_each_entry_safe(encoder, enct, &dev->mode_config.encoder_list, 5428 5493 head) { 5429 5494 encoder->funcs->destroy(encoder); 5430 - } 5431 - 5432 - list_for_each_entry_safe(bridge, brt, 5433 - &dev->mode_config.bridge_list, head) { 5434 - bridge->funcs->destroy(bridge); 5435 5495 } 5436 5496 5437 5497 list_for_each_entry_safe(connector, ot,
+3 -3
drivers/gpu/drm/drm_mipi_dsi.c
··· 323 323 int mipi_dsi_create_packet(struct mipi_dsi_packet *packet, 324 324 const struct mipi_dsi_msg *msg) 325 325 { 326 - const u8 *tx = msg->tx_buf; 327 - 328 326 if (!packet || !msg) 329 327 return -EINVAL; 330 328 ··· 351 353 packet->header[2] = (msg->tx_len >> 8) & 0xff; 352 354 353 355 packet->payload_length = msg->tx_len; 354 - packet->payload = tx; 356 + packet->payload = msg->tx_buf; 355 357 } else { 358 + const u8 *tx = msg->tx_buf; 359 + 356 360 packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0; 357 361 packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0; 358 362 }
+28 -25
drivers/gpu/drm/exynos/exynos_dp_core.c
··· 18 18 #include <linux/interrupt.h> 19 19 #include <linux/of.h> 20 20 #include <linux/of_gpio.h> 21 + #include <linux/of_graph.h> 21 22 #include <linux/gpio.h> 22 23 #include <linux/component.h> 23 24 #include <linux/phy/phy.h> ··· 994 993 .best_encoder = exynos_dp_best_encoder, 995 994 }; 996 995 997 - static bool find_bridge(const char *compat, struct bridge_init *bridge) 998 - { 999 - bridge->client = NULL; 1000 - bridge->node = of_find_compatible_node(NULL, NULL, compat); 1001 - if (!bridge->node) 1002 - return false; 1003 - 1004 - bridge->client = of_find_i2c_device_by_node(bridge->node); 1005 - if (!bridge->client) 1006 - return false; 1007 - 1008 - return true; 1009 - } 1010 - 1011 996 /* returns the number of bridges attached */ 1012 - static int exynos_drm_attach_lcd_bridge(struct drm_device *dev, 997 + static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp, 1013 998 struct drm_encoder *encoder) 1014 999 { 1015 - struct bridge_init bridge; 1016 1000 int ret; 1017 1001 1018 - if (find_bridge("nxp,ptn3460", &bridge)) { 1019 - ret = ptn3460_init(dev, encoder, bridge.client, bridge.node); 1020 - if (!ret) 1021 - return 1; 1002 + encoder->bridge = dp->bridge; 1003 + dp->bridge->encoder = encoder; 1004 + ret = drm_bridge_attach(encoder->dev, dp->bridge); 1005 + if (ret) { 1006 + DRM_ERROR("Failed to attach bridge to drm\n"); 1007 + return ret; 1022 1008 } 1009 + 1023 1010 return 0; 1024 1011 } 1025 1012 ··· 1021 1032 dp->encoder = encoder; 1022 1033 1023 1034 /* Pre-empt DP connector creation if there's a bridge */ 1024 - ret = exynos_drm_attach_lcd_bridge(dp->drm_dev, encoder); 1025 - if (ret) 1026 - return 0; 1035 + if (dp->bridge) { 1036 + ret = exynos_drm_attach_lcd_bridge(dp, encoder); 1037 + if (!ret) 1038 + return 0; 1039 + } 1027 1040 1028 1041 connector->polled = DRM_CONNECTOR_POLL_HPD; 1029 1042 ··· 1232 1241 } 1233 1242 } 1234 1243 1235 - if (!dp->panel) { 1244 + if (!dp->panel && !dp->bridge) { 1236 1245 ret = exynos_dp_dt_parse_panel(dp); 1237 1246 if (ret) 1238 1247 return ret; ··· 1316 1325 static int exynos_dp_probe(struct platform_device *pdev) 1317 1326 { 1318 1327 struct device *dev = &pdev->dev; 1319 - struct device_node *panel_node; 1328 + struct device_node *panel_node, *bridge_node, *endpoint; 1320 1329 struct exynos_dp_device *dp; 1321 1330 int ret; 1322 1331 ··· 1339 1348 dp->panel = of_drm_find_panel(panel_node); 1340 1349 of_node_put(panel_node); 1341 1350 if (!dp->panel) 1351 + return -EPROBE_DEFER; 1352 + } 1353 + 1354 + endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); 1355 + if (endpoint) { 1356 + bridge_node = of_graph_get_remote_port_parent(endpoint); 1357 + if (bridge_node) { 1358 + dp->bridge = of_drm_find_bridge(bridge_node); 1359 + of_node_put(bridge_node); 1360 + if (!dp->bridge) 1361 + return -EPROBE_DEFER; 1362 + } else 1342 1363 return -EPROBE_DEFER; 1343 1364 } 1344 1365
+1
drivers/gpu/drm/exynos/exynos_dp_core.h
··· 153 153 struct drm_connector connector; 154 154 struct drm_encoder *encoder; 155 155 struct drm_panel *panel; 156 + struct drm_bridge *bridge; 156 157 struct clk *clock; 157 158 unsigned int irq; 158 159 void __iomem *reg_base;
+2 -2
drivers/gpu/drm/msm/hdmi/hdmi.c
··· 247 247 return 0; 248 248 249 249 fail: 250 - /* bridge/connector are normally destroyed by drm: */ 250 + /* bridge is normally destroyed by drm: */ 251 251 if (hdmi->bridge) { 252 - hdmi->bridge->funcs->destroy(hdmi->bridge); 252 + hdmi_bridge_destroy(hdmi->bridge); 253 253 hdmi->bridge = NULL; 254 254 } 255 255 if (hdmi->connector) {
+1
drivers/gpu/drm/msm/hdmi/hdmi.h
··· 146 146 */ 147 147 148 148 struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi); 149 + void hdmi_bridge_destroy(struct drm_bridge *bridge); 149 150 150 151 /* 151 152 * hdmi connector:
+3 -4
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
··· 23 23 }; 24 24 #define to_hdmi_bridge(x) container_of(x, struct hdmi_bridge, base) 25 25 26 - static void hdmi_bridge_destroy(struct drm_bridge *bridge) 26 + void hdmi_bridge_destroy(struct drm_bridge *bridge) 27 27 { 28 28 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); 29 - drm_bridge_cleanup(bridge); 30 29 kfree(hdmi_bridge); 31 30 } 32 31 ··· 199 200 .disable = hdmi_bridge_disable, 200 201 .post_disable = hdmi_bridge_post_disable, 201 202 .mode_set = hdmi_bridge_mode_set, 202 - .destroy = hdmi_bridge_destroy, 203 203 }; 204 204 205 205 ··· 218 220 hdmi_bridge->hdmi = hdmi; 219 221 220 222 bridge = &hdmi_bridge->base; 223 + bridge->funcs = &hdmi_bridge_funcs; 221 224 222 - drm_bridge_init(hdmi->dev, bridge, &hdmi_bridge_funcs); 225 + drm_bridge_attach(hdmi->dev, bridge); 223 226 224 227 return bridge; 225 228
+22 -11
drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
··· 19 19 20 20 #include <video/mipi_display.h> 21 21 22 - #include <linux/host1x.h> 23 - 24 22 struct sharp_panel { 25 23 struct drm_panel base; 26 24 /* the datasheet refers to them as DSI-LINK1 and DSI-LINK2 */ ··· 37 39 static inline struct sharp_panel *to_sharp_panel(struct drm_panel *panel) 38 40 { 39 41 return container_of(panel, struct sharp_panel, base); 42 + } 43 + 44 + static void sharp_wait_frames(struct sharp_panel *sharp, unsigned int frames) 45 + { 46 + unsigned int refresh = drm_mode_vrefresh(sharp->mode); 47 + 48 + if (WARN_ON(frames > refresh)) 49 + return; 50 + 51 + msleep(1000 / (refresh / frames)); 40 52 } 41 53 42 54 static int sharp_panel_write(struct sharp_panel *sharp, u16 offset, u8 value) ··· 114 106 if (!sharp->prepared) 115 107 return 0; 116 108 109 + sharp_wait_frames(sharp, 4); 110 + 117 111 err = mipi_dsi_dcs_set_display_off(sharp->link1); 118 112 if (err < 0) 119 113 dev_err(panel->dev, "failed to set display off: %d\n", err); ··· 180 170 if (err < 0) 181 171 return err; 182 172 183 - usleep_range(10000, 20000); 184 - 185 - err = mipi_dsi_dcs_soft_reset(sharp->link1); 186 - if (err < 0) { 187 - dev_err(panel->dev, "soft reset failed: %d\n", err); 188 - goto poweroff; 189 - } 190 - 191 - msleep(120); 173 + /* 174 + * According to the datasheet, the panel needs around 10 ms to fully 175 + * power up. At least another 120 ms is required before exiting sleep 176 + * mode to make sure the panel is ready. Throw in another 20 ms for 177 + * good measure. 178 + */ 179 + msleep(150); 192 180 193 181 err = mipi_dsi_dcs_exit_sleep_mode(sharp->link1); 194 182 if (err < 0) { ··· 245 237 } 246 238 247 239 sharp->prepared = true; 240 + 241 + /* wait for 6 frames before continuing */ 242 + sharp_wait_frames(sharp, 6); 248 243 249 244 return 0; 250 245
+57
drivers/gpu/drm/panel/panel-simple.c
··· 448 448 }, 449 449 }; 450 450 451 + static const struct drm_display_mode avic_tm070ddh03_mode = { 452 + .clock = 51200, 453 + .hdisplay = 1024, 454 + .hsync_start = 1024 + 160, 455 + .hsync_end = 1024 + 160 + 4, 456 + .htotal = 1024 + 160 + 4 + 156, 457 + .vdisplay = 600, 458 + .vsync_start = 600 + 17, 459 + .vsync_end = 600 + 17 + 1, 460 + .vtotal = 600 + 17 + 1 + 17, 461 + .vrefresh = 60, 462 + }; 463 + 464 + static const struct panel_desc avic_tm070ddh03 = { 465 + .modes = &avic_tm070ddh03_mode, 466 + .num_modes = 1, 467 + .bpc = 8, 468 + .size = { 469 + .width = 154, 470 + .height = 90, 471 + }, 472 + .delay = { 473 + .prepare = 20, 474 + .enable = 200, 475 + .disable = 200, 476 + }, 477 + }; 478 + 451 479 static const struct drm_display_mode chunghwa_claa101wa01a_mode = { 452 480 .clock = 72070, 453 481 .hdisplay = 1366, ··· 592 564 .height = 65, 593 565 }, 594 566 .bus_format = MEDIA_BUS_FMT_RGB888_1X24, 567 + }; 568 + 569 + static const struct drm_display_mode giantplus_gpg482739qs5_mode = { 570 + .clock = 9000, 571 + .hdisplay = 480, 572 + .hsync_start = 480 + 5, 573 + .hsync_end = 480 + 5 + 1, 574 + .htotal = 480 + 5 + 1 + 40, 575 + .vdisplay = 272, 576 + .vsync_start = 272 + 8, 577 + .vsync_end = 272 + 8 + 1, 578 + .vtotal = 272 + 8 + 1 + 8, 579 + .vrefresh = 60, 580 + }; 581 + 582 + static const struct panel_desc giantplus_gpg482739qs5 = { 583 + .modes = &giantplus_gpg482739qs5_mode, 584 + .num_modes = 1, 585 + .bpc = 8, 586 + .size = { 587 + .width = 95, 588 + .height = 54, 589 + }, 595 590 }; 596 591 597 592 static const struct drm_display_mode hannstar_hsd070pww1_mode = { ··· 796 745 .compatible = "auo,b133xtn01", 797 746 .data = &auo_b133xtn01, 798 747 }, { 748 + .compatible = "avic,tm070ddh03", 749 + .data = &avic_tm070ddh03, 750 + }, { 799 751 .compatible = "chunghwa,claa101wa01a", 800 752 .data = &chunghwa_claa101wa01a 801 753 }, { ··· 816 762 }, { 817 763 .compatible = "foxlink,fl500wvr00-a0t", 818 764 .data = &foxlink_fl500wvr00_a0t, 765 + }, { 766 + .compatible = "giantplus,gpg482739qs5", 767 + .data = &giantplus_gpg482739qs5 819 768 }, { 820 769 .compatible = "hannstar,hsd070pww1", 821 770 .data = &hannstar_hsd070pww1,
+19 -10
drivers/gpu/drm/sti/sti_dvo.c
··· 91 91 struct dvo_config *config; 92 92 bool enabled; 93 93 struct drm_encoder *encoder; 94 + struct drm_bridge *bridge; 94 95 }; 95 96 96 97 struct sti_dvo_connector { ··· 273 272 /* do nothing */ 274 273 } 275 274 276 - static void sti_dvo_brigde_destroy(struct drm_bridge *bridge) 277 - { 278 - drm_bridge_cleanup(bridge); 279 - kfree(bridge); 280 - } 281 - 282 275 static const struct drm_bridge_funcs sti_dvo_bridge_funcs = { 283 276 .pre_enable = sti_dvo_pre_enable, 284 277 .enable = sti_dvo_bridge_nope, 285 278 .disable = sti_dvo_disable, 286 279 .post_disable = sti_dvo_bridge_nope, 287 280 .mode_set = sti_dvo_set_mode, 288 - .destroy = sti_dvo_brigde_destroy, 289 281 }; 290 282 291 283 static int sti_dvo_connector_get_modes(struct drm_connector *connector) ··· 410 416 return -ENOMEM; 411 417 412 418 bridge->driver_private = dvo; 413 - drm_bridge_init(drm_dev, bridge, &sti_dvo_bridge_funcs); 419 + bridge->funcs = &sti_dvo_bridge_funcs; 420 + bridge->of_node = dvo->dev.of_node; 421 + err = drm_bridge_add(bridge); 422 + if (err) { 423 + DRM_ERROR("Failed to add bridge\n"); 424 + return err; 425 + } 414 426 427 + err = drm_bridge_attach(drm_dev, bridge); 428 + if (err) { 429 + DRM_ERROR("Failed to attach bridge\n"); 430 + return err; 431 + } 432 + 433 + dvo->bridge = bridge; 415 434 encoder->bridge = bridge; 416 435 connector->encoder = encoder; 417 436 dvo->encoder = encoder; ··· 453 446 err_sysfs: 454 447 drm_connector_unregister(drm_connector); 455 448 err_connector: 456 - drm_bridge_cleanup(bridge); 449 + drm_bridge_remove(bridge); 457 450 drm_connector_cleanup(drm_connector); 458 451 return -EINVAL; 459 452 } ··· 461 454 static void sti_dvo_unbind(struct device *dev, 462 455 struct device *master, void *data) 463 456 { 464 - /* do nothing */ 457 + struct sti_dvo *dvo = dev_get_drvdata(dev); 458 + 459 + drm_bridge_remove(dvo->bridge); 465 460 } 466 461 467 462 static const struct component_ops sti_dvo_ops = {
+2 -9
drivers/gpu/drm/sti/sti_hda.c
··· 508 508 /* do nothing */ 509 509 } 510 510 511 - static void sti_hda_brigde_destroy(struct drm_bridge *bridge) 512 - { 513 - drm_bridge_cleanup(bridge); 514 - kfree(bridge); 515 - } 516 - 517 511 static const struct drm_bridge_funcs sti_hda_bridge_funcs = { 518 512 .pre_enable = sti_hda_pre_enable, 519 513 .enable = sti_hda_bridge_nope, 520 514 .disable = sti_hda_disable, 521 515 .post_disable = sti_hda_bridge_nope, 522 516 .mode_set = sti_hda_set_mode, 523 - .destroy = sti_hda_brigde_destroy, 524 517 }; 525 518 526 519 static int sti_hda_connector_get_modes(struct drm_connector *connector) ··· 657 664 return -ENOMEM; 658 665 659 666 bridge->driver_private = hda; 660 - drm_bridge_init(drm_dev, bridge, &sti_hda_bridge_funcs); 667 + bridge->funcs = &sti_hda_bridge_funcs; 668 + drm_bridge_attach(drm_dev, bridge); 661 669 662 670 encoder->bridge = bridge; 663 671 connector->encoder = encoder; ··· 687 693 err_sysfs: 688 694 drm_connector_unregister(drm_connector); 689 695 err_connector: 690 - drm_bridge_cleanup(bridge); 691 696 drm_connector_cleanup(drm_connector); 692 697 return -EINVAL; 693 698 }
+2 -9
drivers/gpu/drm/sti/sti_hdmi.c
··· 463 463 /* do nothing */ 464 464 } 465 465 466 - static void sti_hdmi_brigde_destroy(struct drm_bridge *bridge) 467 - { 468 - drm_bridge_cleanup(bridge); 469 - kfree(bridge); 470 - } 471 - 472 466 static const struct drm_bridge_funcs sti_hdmi_bridge_funcs = { 473 467 .pre_enable = sti_hdmi_pre_enable, 474 468 .enable = sti_hdmi_bridge_nope, 475 469 .disable = sti_hdmi_disable, 476 470 .post_disable = sti_hdmi_bridge_nope, 477 471 .mode_set = sti_hdmi_set_mode, 478 - .destroy = sti_hdmi_brigde_destroy, 479 472 }; 480 473 481 474 static int sti_hdmi_connector_get_modes(struct drm_connector *connector) ··· 628 635 goto err_adapt; 629 636 630 637 bridge->driver_private = hdmi; 631 - drm_bridge_init(drm_dev, bridge, &sti_hdmi_bridge_funcs); 638 + bridge->funcs = &sti_hdmi_bridge_funcs; 639 + drm_bridge_attach(drm_dev, bridge); 632 640 633 641 encoder->bridge = bridge; 634 642 connector->encoder = encoder; ··· 661 667 err_sysfs: 662 668 drm_connector_unregister(drm_connector); 663 669 err_connector: 664 - drm_bridge_cleanup(bridge); 665 670 drm_connector_cleanup(drm_connector); 666 671 err_adapt: 667 672 put_device(&hdmi->ddc_adapt->dev);
+8
include/drm/bridge/ptn3460.h
··· 15 15 #define _DRM_BRIDGE_PTN3460_H_ 16 16 17 17 struct drm_device; 18 + struct drm_bridge; 18 19 struct drm_encoder; 19 20 struct i2c_client; 20 21 struct device_node; ··· 24 23 25 24 int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder, 26 25 struct i2c_client *client, struct device_node *node); 26 + 27 + void ptn3460_destroy(struct drm_bridge *bridge); 28 + 27 29 #else 28 30 29 31 static inline int ptn3460_init(struct drm_device *dev, ··· 34 30 struct device_node *node) 35 31 { 36 32 return 0; 33 + } 34 + 35 + static inline void ptn3460_destroy(struct drm_bridge *bridge) 36 + { 37 37 } 38 38 39 39 #endif
+13 -14
include/drm/drm_crtc.h
··· 868 868 869 869 /** 870 870 * struct drm_bridge_funcs - drm_bridge control functions 871 + * @attach: Called during drm_bridge_attach 871 872 * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge 872 873 * @disable: Called right before encoder prepare, disables the bridge 873 874 * @post_disable: Called right after encoder prepare, for lockstepped disable 874 875 * @mode_set: Set this mode to the bridge 875 876 * @pre_enable: Called right before encoder commit, for lockstepped commit 876 877 * @enable: Called right after encoder commit, enables the bridge 877 - * @destroy: make object go away 878 878 */ 879 879 struct drm_bridge_funcs { 880 + int (*attach)(struct drm_bridge *bridge); 880 881 bool (*mode_fixup)(struct drm_bridge *bridge, 881 882 const struct drm_display_mode *mode, 882 883 struct drm_display_mode *adjusted_mode); ··· 888 887 struct drm_display_mode *adjusted_mode); 889 888 void (*pre_enable)(struct drm_bridge *bridge); 890 889 void (*enable)(struct drm_bridge *bridge); 891 - void (*destroy)(struct drm_bridge *bridge); 892 890 }; 893 891 894 892 /** 895 893 * struct drm_bridge - central DRM bridge control structure 896 894 * @dev: DRM device this bridge belongs to 897 - * @head: list management 895 + * @of_node: device node pointer to the bridge 896 + * @list: to keep track of all added bridges 898 897 * @base: base mode object 899 898 * @funcs: control functions 900 899 * @driver_private: pointer to the bridge driver's internal context 901 900 */ 902 901 struct drm_bridge { 903 902 struct drm_device *dev; 904 - struct list_head head; 905 - 906 - struct drm_mode_object base; 903 + struct drm_encoder *encoder; 904 + #ifdef CONFIG_OF 905 + struct device_node *of_node; 906 + #endif 907 + struct list_head list; 907 908 908 909 const struct drm_bridge_funcs *funcs; 909 910 void *driver_private; ··· 1010 1007 uint32_t num_crtcs; 1011 1008 uint32_t num_encoders; 1012 1009 uint32_t num_connectors; 1013 - uint32_t num_bridges; 1014 1010 1015 1011 /* list of object IDs for this group */ 1016 1012 uint32_t *id_list; ··· 1028 1026 * @fb_list: list of framebuffers available 1029 1027 * @num_connector: number of connectors on this device 1030 1028 * @connector_list: list of connector objects 1031 - * @num_bridge: number of bridges on this device 1032 - * @bridge_list: list of bridge objects 1033 1029 * @num_encoder: number of encoders on this device 1034 1030 * @encoder_list: list of encoder objects 1035 1031 * @num_overlay_plane: number of overlay planes on this device ··· 1072 1072 1073 1073 int num_connector; 1074 1074 struct list_head connector_list; 1075 - int num_bridge; 1076 - struct list_head bridge_list; 1077 1075 int num_encoder; 1078 1076 struct list_head encoder_list; 1079 1077 ··· 1220 1222 /* helper to unplug all connectors from sysfs for device */ 1221 1223 extern void drm_connector_unplug_all(struct drm_device *dev); 1222 1224 1223 - extern int drm_bridge_init(struct drm_device *dev, struct drm_bridge *bridge, 1224 - const struct drm_bridge_funcs *funcs); 1225 - extern void drm_bridge_cleanup(struct drm_bridge *bridge); 1225 + extern int drm_bridge_add(struct drm_bridge *bridge); 1226 + extern void drm_bridge_remove(struct drm_bridge *bridge); 1227 + extern struct drm_bridge *of_drm_find_bridge(struct device_node *np); 1228 + extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge); 1226 1229 1227 1230 extern int drm_encoder_init(struct drm_device *dev, 1228 1231 struct drm_encoder *encoder,