- Add default modes for connectors in unknown state - R-Car DU conversion to DRM-managed API - R-Car DU miscellaneous fixes - Miscellaneous bridge and bridge bindings fixes - Assorted misc driver cleanups - Constify drm_driver for PCI devices
Unified · Split
| @@ -83,9 +83,9 @@ properties: · 82 unmodified lines | ||
| 83 | 83 | $ref: /schemas/types.yaml#/definitions/phandle |
| 84 | 84 | description: |
| 85 | 85 | phandle to the companion LVDS encoder. This property is mandatory |
| 86 | − for the first LVDS encoder on D3 and E3 SoCs, and shall point to | |
| 87 | − the second encoder to be used as a companion in dual-link mode. It | |
| 88 | − shall not be set for any other LVDS encoder. | |
| 86 | + for the first LVDS encoder on R-Car D3 and E3, and RZ/G2E SoCs, and shall | |
| 87 | + point to the second encoder to be used as a companion in dual-link mode. | |
| 88 | + It shall not be set for any other LVDS encoder. | |
| 89 | 89 | |
| 90 | 90 | required: |
| 91 | 91 | - compatible |
| @@ -30,11 +30,17 @@ properties: · 29 unmodified lines | ||
| 30 | 30 | This device has four video ports. Their connections are modeled using the |
| 31 | 31 | OF graph bindings specified in Documentation/devicetree/bindings/graph.txt. |
| 32 | 32 | |
| 33 | − The device can operate in single-link mode or dual-link mode. In | |
| 34 | − single-link mode, all pixels are received on port@0, and port@1 shall not | |
| 35 | − contain any endpoint. In dual-link mode, even-numbered pixels are | |
| 36 | − received on port@0 and odd-numbered pixels on port@1, and both port@0 and | |
| 37 | − port@1 shall contain endpoints. | |
| 33 | + The device can operate in single or dual input and output modes. | |
| 34 | + | |
| 35 | + When operating in single input mode, all pixels are received on port@0, | |
| 36 | + and port@1 shall not contain any endpoint. In dual input mode, | |
| 37 | + even-numbered pixels are received on port@0 and odd-numbered pixels on | |
| 38 | + port@1, and both port@0 and port@1 shall contain endpoints. | |
| 39 | + | |
| 40 | + When operating in single output mode all pixels are output from the first | |
| 41 | + CMOS/TTL port and port@3 shall not contain any endpoint. In dual output | |
| 42 | + mode pixels are output from both CMOS/TTL ports and both port@2 and | |
| 43 | + port@3 shall contain endpoints. | |
| 38 | 44 | |
| 39 | 45 | properties: |
| 40 | 46 | '#address-cells': |
| @@ -162,15 +162,10 @@ static const struct drm_plane_helper_funcs arc_pgu_plane_helper_funcs = { · 161 unmodified lines | ||
| 162 | 162 | .atomic_update = arc_pgu_plane_atomic_update, |
| 163 | 163 | }; |
| 164 | 164 | |
| 165 | −static void arc_pgu_plane_destroy(struct drm_plane *plane) | |
| 166 | −{ | |
| 167 | − drm_plane_cleanup(plane); | |
| 168 | −} | |
| 169 | − | |
| 170 | 165 | static const struct drm_plane_funcs arc_pgu_plane_funcs = { |
| 171 | 166 | .update_plane = drm_atomic_helper_update_plane, |
| 172 | 167 | .disable_plane = drm_atomic_helper_disable_plane, |
| 173 | − .destroy = arc_pgu_plane_destroy, | |
| 168 | + .destroy = drm_plane_cleanup, | |
| 174 | 169 | .reset = drm_atomic_helper_plane_reset, |
| 175 | 170 | .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, |
| 176 | 171 | .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, |
| @@ -213,7 +208,7 @@ int arc_pgu_setup_crtc(struct drm_device *drm) · 36 unmodified lines | ||
| 213 | 208 | ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, primary, NULL, |
| 214 | 209 | &arc_pgu_crtc_funcs, NULL); |
| 215 | 210 | if (ret) { |
| 216 | − arc_pgu_plane_destroy(primary); | |
| 211 | + drm_plane_cleanup(primary); | |
| 217 | 212 | return ret; |
| 218 | 213 | } |
| 219 | 214 | |
| @@ -145,7 +145,7 @@ static void arcpgu_debugfs_init(struct drm_minor *minor) · 144 unmodified lines | ||
| 145 | 145 | } |
| 146 | 146 | #endif |
| 147 | 147 | |
| 148 | −static struct drm_driver arcpgu_drm_driver = { | |
| 148 | +static const struct drm_driver arcpgu_drm_driver = { | |
| 149 | 149 | .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC, |
| 150 | 150 | .name = "arcpgu", |
| 151 | 151 | .desc = "ARC PGU Controller", |
| @@ -1292,8 +1292,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) · 1291 unmodified lines | ||
| 1292 | 1292 | |
| 1293 | 1293 | err_unregister_cec: |
| 1294 | 1294 | i2c_unregister_device(adv7511->i2c_cec); |
| 1295 | − if (adv7511->cec_clk) | |
| 1296 | − clk_disable_unprepare(adv7511->cec_clk); | |
| 1295 | + clk_disable_unprepare(adv7511->cec_clk); | |
| 1297 | 1296 | err_i2c_unregister_packet: |
| 1298 | 1297 | i2c_unregister_device(adv7511->i2c_packet); |
| 1299 | 1298 | err_i2c_unregister_edid: |
| @@ -1311,8 +1310,7 @@ static int adv7511_remove(struct i2c_client *i2c) · 11 unmodified lines | ||
| 1311 | 1310 | if (adv7511->type == ADV7533 || adv7511->type == ADV7535) |
| 1312 | 1311 | adv7533_detach_dsi(adv7511); |
| 1313 | 1312 | i2c_unregister_device(adv7511->i2c_cec); |
| 1314 | − if (adv7511->cec_clk) | |
| 1315 | − clk_disable_unprepare(adv7511->cec_clk); | |
| 1313 | + clk_disable_unprepare(adv7511->cec_clk); | |
| 1316 | 1314 | |
| 1317 | 1315 | adv7511_uninit_regulators(adv7511); |
| 1318 | 1316 | |
| @@ -3440,8 +3440,7 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, · 3439 unmodified lines | ||
| 3440 | 3440 | |
| 3441 | 3441 | err_iahb: |
| 3442 | 3442 | clk_disable_unprepare(hdmi->iahb_clk); |
| 3443 | − if (hdmi->cec_clk) | |
| 3444 | − clk_disable_unprepare(hdmi->cec_clk); | |
| 3443 | + clk_disable_unprepare(hdmi->cec_clk); | |
| 3445 | 3444 | err_isfr: |
| 3446 | 3445 | clk_disable_unprepare(hdmi->isfr_clk); |
| 3447 | 3446 | err_res: |
| @@ -3465,8 +3464,7 @@ void dw_hdmi_remove(struct dw_hdmi *hdmi) · 17 unmodified lines | ||
| 3465 | 3464 | |
| 3466 | 3465 | clk_disable_unprepare(hdmi->iahb_clk); |
| 3467 | 3466 | clk_disable_unprepare(hdmi->isfr_clk); |
| 3468 | − if (hdmi->cec_clk) | |
| 3469 | − clk_disable_unprepare(hdmi->cec_clk); | |
| 3467 | + clk_disable_unprepare(hdmi->cec_clk); | |
| 3470 | 3468 | |
| 3471 | 3469 | if (hdmi->i2c) |
| 3472 | 3470 | i2c_del_adapter(&hdmi->i2c->adap); |
| @@ -202,7 +202,7 @@ static int thc63_probe(struct platform_device *pdev) · 201 unmodified lines | ||
| 202 | 202 | thc63->dev = &pdev->dev; |
| 203 | 203 | platform_set_drvdata(pdev, thc63); |
| 204 | 204 | |
| 205 | − thc63->vcc = devm_regulator_get_optional(thc63->dev, "vcc"); | |
| 205 | + thc63->vcc = devm_regulator_get(thc63->dev, "vcc"); | |
| 206 | 206 | if (IS_ERR(thc63->vcc)) { |
| 207 | 207 | if (PTR_ERR(thc63->vcc) == -EPROBE_DEFER) |
| 208 | 208 | return -EPROBE_DEFER; |
| @@ -589,11 +589,7 @@ static int drm_dev_init(struct drm_device *dev, · 588 unmodified lines | ||
| 589 | 589 | |
| 590 | 590 | kref_init(&dev->ref); |
| 591 | 591 | dev->dev = get_device(parent); |
| 592 | −#ifdef CONFIG_DRM_LEGACY | |
| 593 | − dev->driver = (struct drm_driver *)driver; | |
| 594 | −#else | |
| 595 | 592 | dev->driver = driver; |
| 596 | −#endif | |
| 597 | 593 | |
| 598 | 594 | INIT_LIST_HEAD(&dev->managed.resources); |
| 599 | 595 | spin_lock_init(&dev->managed.lock); |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include <drm/drm_mode.h> |
| 30 | 30 | |
| 31 | 31 | #include "drm_crtc_internal.h" |
| 32 | +#include "drm_internal.h" | |
| 32 | 33 | |
| 33 | 34 | /** |
| 34 | 35 | * DOC: overview |
| @@ -46,9 +47,10 @@ · 11 unmodified lines | ||
| 46 | 47 | * KMS frame buffers. |
| 47 | 48 | * |
| 48 | 49 | * To support dumb objects drivers must implement the &drm_driver.dumb_create |
| 49 | − * operation. &drm_driver.dumb_destroy defaults to drm_gem_dumb_destroy() if | |
| 50 | − * not set and &drm_driver.dumb_map_offset defaults to | |
| 51 | − * drm_gem_dumb_map_offset(). See the callbacks for further details. | |
| 50 | + * and &drm_driver.dumb_map_offset operations (the latter defaults to | |
| 51 | + * drm_gem_dumb_map_offset() if not set). Drivers that don't use GEM handles | |
| 52 | + * additionally need to implement the &drm_driver.dumb_destroy operation. See | |
| 53 | + * the callbacks for further details. | |
| 52 | 54 | * |
| 53 | 55 | * Note that dumb objects may not be used for gpu acceleration, as has been |
| 54 | 56 | * attempted on some ARM embedded platforms. Such drivers really must have |
| @@ -335,22 +335,12 @@ out: · 334 unmodified lines | ||
| 335 | 335 | } |
| 336 | 336 | EXPORT_SYMBOL_GPL(drm_gem_dumb_map_offset); |
| 337 | 337 | |
| 338 | −/** | |
| 339 | − * drm_gem_dumb_destroy - dumb fb callback helper for gem based drivers | |
| 340 | − * @file: drm file-private structure to remove the dumb handle from | |
| 341 | − * @dev: corresponding drm_device | |
| 342 | − * @handle: the dumb handle to remove | |
| 343 | − * | |
| 344 | − * This implements the &drm_driver.dumb_destroy kms driver callback for drivers | |
| 345 | − * which use gem to manage their backing storage. | |
| 346 | − */ | |
| 347 | 338 | int drm_gem_dumb_destroy(struct drm_file *file, |
| 348 | 339 | struct drm_device *dev, |
| 349 | − uint32_t handle) | |
| 340 | + u32 handle) | |
| 350 | 341 | { |
| 351 | 342 | return drm_gem_handle_delete(file, handle); |
| 352 | 343 | } |
| 353 | −EXPORT_SYMBOL(drm_gem_dumb_destroy); | |
| 354 | 344 | |
| 355 | 345 | /** |
| 356 | 346 | * drm_gem_handle_create_tail - internal functions to create a handle |
| @@ -191,6 +191,9 @@ void drm_gem_unpin(struct drm_gem_object *obj); · 190 unmodified lines | ||
| 191 | 191 | int drm_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map); |
| 192 | 192 | void drm_gem_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map); |
| 193 | 193 | |
| 194 | +int drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev, | |
| 195 | + u32 handle); | |
| 196 | + | |
| 194 | 197 | /* drm_debugfs.c drm_debugfs_crc.c */ |
| 195 | 198 | #if defined(CONFIG_DEBUG_FS) |
| 196 | 199 | int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
| @@ -24,6 +24,8 @@ · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | #include <linux/dma-mapping.h> |
| 26 | 26 | #include <linux/export.h> |
| 27 | +#include <linux/list.h> | |
| 28 | +#include <linux/mutex.h> | |
| 27 | 29 | #include <linux/pci.h> |
| 28 | 30 | #include <linux/slab.h> |
| 29 | 31 | |
| @@ -36,6 +38,9 @@ · 6 unmodified lines | ||
| 36 | 38 | #include "drm_legacy.h" |
| 37 | 39 | |
| 38 | 40 | #ifdef CONFIG_DRM_LEGACY |
| 41 | +/* List of devices hanging off drivers with stealth attach. */ | |
| 42 | +static LIST_HEAD(legacy_dev_list); | |
| 43 | +static DEFINE_MUTEX(legacy_dev_list_lock); | |
| 39 | 44 | |
| 40 | 45 | /** |
| 41 | 46 | * drm_pci_alloc - Allocate a PCI consistent memory block, for DMA. |
| @@ -196,7 +201,7 @@ static void drm_pci_agp_init(struct drm_device *dev) · 154 unmodified lines | ||
| 196 | 201 | |
| 197 | 202 | static int drm_get_pci_dev(struct pci_dev *pdev, |
| 198 | 203 | const struct pci_device_id *ent, |
| 199 | − struct drm_driver *driver) | |
| 204 | + const struct drm_driver *driver) | |
| 200 | 205 | { |
| 201 | 206 | struct drm_device *dev; |
| 202 | 207 | int ret; |
| @@ -225,10 +230,11 @@ static int drm_get_pci_dev(struct pci_dev *pdev, · 22 unmodified lines | ||
| 225 | 230 | if (ret) |
| 226 | 231 | goto err_agp; |
| 227 | 232 | |
| 228 | − /* No locking needed since shadow-attach is single-threaded since it may | |
| 229 | − * only be called from the per-driver module init hook. */ | |
| 230 | − if (drm_core_check_feature(dev, DRIVER_LEGACY)) | |
| 231 | − list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list); | |
| 233 | + if (drm_core_check_feature(dev, DRIVER_LEGACY)) { | |
| 234 | + mutex_lock(&legacy_dev_list_lock); | |
| 235 | + list_add_tail(&dev->legacy_dev_list, &legacy_dev_list); | |
| 236 | + mutex_unlock(&legacy_dev_list_lock); | |
| 237 | + } | |
| 232 | 238 | |
| 233 | 239 | return 0; |
| 234 | 240 | |
| @@ -249,7 +255,8 @@ err_free: · 14 unmodified lines | ||
| 249 | 255 | * |
| 250 | 256 | * Return: 0 on success or a negative error code on failure. |
| 251 | 257 | */ |
| 252 | −int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) | |
| 258 | +int drm_legacy_pci_init(const struct drm_driver *driver, | |
| 259 | + struct pci_driver *pdriver) | |
| 253 | 260 | { |
| 254 | 261 | struct pci_dev *pdev = NULL; |
| 255 | 262 | const struct pci_device_id *pid; |
| @@ -261,7 +268,6 @@ int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) · 5 unmodified lines | ||
| 261 | 268 | return -EINVAL; |
| 262 | 269 | |
| 263 | 270 | /* If not using KMS, fall back to stealth mode manual scanning. */ |
| 264 | − INIT_LIST_HEAD(&driver->legacy_dev_list); | |
| 265 | 271 | for (i = 0; pdriver->id_table[i].vendor != 0; i++) { |
| 266 | 272 | pid = &pdriver->id_table[i]; |
| 267 | 273 | |
| @@ -295,7 +301,8 @@ EXPORT_SYMBOL(drm_legacy_pci_init); · 27 unmodified lines | ||
| 295 | 301 | * Unregister a DRM driver shadow-attached through drm_legacy_pci_init(). This |
| 296 | 302 | * is deprecated and only used by dri1 drivers. |
| 297 | 303 | */ |
| 298 | −void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) | |
| 304 | +void drm_legacy_pci_exit(const struct drm_driver *driver, | |
| 305 | + struct pci_driver *pdriver) | |
| 299 | 306 | { |
| 300 | 307 | struct drm_device *dev, *tmp; |
| 301 | 308 | |
| @@ -304,11 +311,15 @@ void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) · 2 unmodified lines | ||
| 304 | 311 | if (!(driver->driver_features & DRIVER_LEGACY)) { |
| 305 | 312 | WARN_ON(1); |
| 306 | 313 | } else { |
| 307 | − list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list, | |
| 314 | + mutex_lock(&legacy_dev_list_lock); | |
| 315 | + list_for_each_entry_safe(dev, tmp, &legacy_dev_list, | |
| 308 | 316 | legacy_dev_list) { |
| 309 | − list_del(&dev->legacy_dev_list); | |
| 310 | − drm_put_dev(dev); | |
| 317 | + if (dev->driver == driver) { | |
| 318 | + list_del(&dev->legacy_dev_list); | |
| 319 | + drm_put_dev(dev); | |
| 320 | + } | |
| 311 | 321 | } |
| 322 | + mutex_unlock(&legacy_dev_list_lock); | |
| 312 | 323 | } |
| 313 | 324 | DRM_INFO("Module unloaded\n"); |
| 314 | 325 | } |
| @@ -515,7 +515,8 @@ retry: · 514 unmodified lines | ||
| 515 | 515 | if (count == 0 && connector->status == connector_status_connected) |
| 516 | 516 | count = drm_add_override_edid_modes(connector); |
| 517 | 517 | |
| 518 | − if (count == 0 && connector->status == connector_status_connected) | |
| 518 | + if (count == 0 && (connector->status == connector_status_connected || | |
| 519 | + connector->status == connector_status_unknown)) | |
| 519 | 520 | count = drm_add_modes_noedid(connector, 1024, 768); |
| 520 | 521 | count += drm_helper_probe_add_cmdline_mode(connector); |
| 521 | 522 | if (count == 0) |
| @@ -400,7 +400,7 @@ static void kmb_irq_reset(struct drm_device *drm) · 399 unmodified lines | ||
| 400 | 400 | |
| 401 | 401 | DEFINE_DRM_GEM_CMA_FOPS(fops); |
| 402 | 402 | |
| 403 | −static struct drm_driver kmb_driver = { | |
| 403 | +static const struct drm_driver kmb_driver = { | |
| 404 | 404 | .driver_features = DRIVER_GEM | |
| 405 | 405 | DRIVER_MODESET | DRIVER_ATOMIC, |
| 406 | 406 | .irq_handler = kmb_isr, |
| @@ -122,7 +122,7 @@ int rcar_cmm_enable(struct platform_device *pdev) · 121 unmodified lines | ||
| 122 | 122 | { |
| 123 | 123 | int ret; |
| 124 | 124 | |
| 125 | − ret = pm_runtime_get_sync(&pdev->dev); | |
| 125 | + ret = pm_runtime_resume_and_get(&pdev->dev); | |
| 126 | 126 | if (ret < 0) |
| 127 | 127 | return ret; |
| 128 | 128 | |
| @@ -730,13 +730,10 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc, · 729 unmodified lines | ||
| 730 | 730 | */ |
| 731 | 731 | if (rcdu->info->lvds_clk_mask & BIT(rcrtc->index) && |
| 732 | 732 | rstate->outputs == BIT(RCAR_DU_OUTPUT_DPAD0)) { |
| 733 | − struct rcar_du_encoder *encoder = | |
| 734 | − rcdu->encoders[RCAR_DU_OUTPUT_LVDS0 + rcrtc->index]; | |
| 733 | + struct drm_bridge *bridge = rcdu->lvds[rcrtc->index]; | |
| 735 | 734 | const struct drm_display_mode *mode = |
| 736 | 735 | &crtc->state->adjusted_mode; |
| 737 | − struct drm_bridge *bridge; | |
| 738 | 736 | |
| 739 | − bridge = drm_bridge_chain_get_first_bridge(&encoder->base); | |
| 740 | 737 | rcar_lvds_clk_enable(bridge, mode->clock * 1000); |
| 741 | 738 | } |
| 742 | 739 | |
| @@ -764,15 +761,12 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc, · 21 unmodified lines | ||
| 764 | 761 | |
| 765 | 762 | if (rcdu->info->lvds_clk_mask & BIT(rcrtc->index) && |
| 766 | 763 | rstate->outputs == BIT(RCAR_DU_OUTPUT_DPAD0)) { |
| 767 | − struct rcar_du_encoder *encoder = | |
| 768 | − rcdu->encoders[RCAR_DU_OUTPUT_LVDS0 + rcrtc->index]; | |
| 769 | − struct drm_bridge *bridge; | |
| 764 | + struct drm_bridge *bridge = rcdu->lvds[rcrtc->index]; | |
| 770 | 765 | |
| 771 | 766 | /* |
| 772 | 767 | * Disable the LVDS clock output, see |
| 773 | 768 | * rcar_du_crtc_atomic_enable(). |
| 774 | 769 | */ |
| 775 | − bridge = drm_bridge_chain_get_first_bridge(&encoder->base); | |
| 776 | 770 | rcar_lvds_clk_disable(bridge); |
| 777 | 771 | } |
| 778 | 772 | |
| @@ -1256,7 +1250,7 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex, · 477 unmodified lines | ||
| 1256 | 1250 | else |
| 1257 | 1251 | primary = &rgrp->planes[swindex % 2].plane; |
| 1258 | 1252 | |
| 1259 | − ret = drm_crtc_init_with_planes(rcdu->ddev, crtc, primary, NULL, | |
| 1253 | + ret = drm_crtc_init_with_planes(&rcdu->ddev, crtc, primary, NULL, | |
| 1260 | 1254 | rcdu->info->gen <= 2 ? |
| 1261 | 1255 | &crtc_funcs_gen2 : &crtc_funcs_gen3, |
| 1262 | 1256 | NULL); |
| @@ -18,10 +18,11 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <linux/wait.h> |
| 19 | 19 | |
| 20 | 20 | #include <drm/drm_atomic_helper.h> |
| 21 | +#include <drm/drm_drv.h> | |
| 21 | 22 | #include <drm/drm_fb_cma_helper.h> |
| 22 | 23 | #include <drm/drm_fb_helper.h> |
| 23 | −#include <drm/drm_drv.h> | |
| 24 | 24 | #include <drm/drm_gem_cma_helper.h> |
| 25 | +#include <drm/drm_managed.h> | |
| 25 | 26 | #include <drm/drm_probe_helper.h> |
| 26 | 27 | |
| 27 | 28 | #include "rcar_du_drv.h" |
| @@ -527,14 +528,14 @@ static int rcar_du_pm_suspend(struct device *dev) · 499 unmodified lines | ||
| 527 | 528 | { |
| 528 | 529 | struct rcar_du_device *rcdu = dev_get_drvdata(dev); |
| 529 | 530 | |
| 530 | − return drm_mode_config_helper_suspend(rcdu->ddev); | |
| 531 | + return drm_mode_config_helper_suspend(&rcdu->ddev); | |
| 531 | 532 | } |
| 532 | 533 | |
| 533 | 534 | static int rcar_du_pm_resume(struct device *dev) |
| 534 | 535 | { |
| 535 | 536 | struct rcar_du_device *rcdu = dev_get_drvdata(dev); |
| 536 | 537 | |
| 537 | − return drm_mode_config_helper_resume(rcdu->ddev); | |
| 538 | + return drm_mode_config_helper_resume(&rcdu->ddev); | |
| 538 | 539 | } |
| 539 | 540 | #endif |
| 540 | 541 | |
| @@ -549,7 +550,7 @@ static const struct dev_pm_ops rcar_du_pm_ops = { · 8 unmodified lines | ||
| 549 | 550 | static int rcar_du_remove(struct platform_device *pdev) |
| 550 | 551 | { |
| 551 | 552 | struct rcar_du_device *rcdu = platform_get_drvdata(pdev); |
| 552 | − struct drm_device *ddev = rcdu->ddev; | |
| 553 | + struct drm_device *ddev = &rcdu->ddev; | |
| 553 | 554 | |
| 554 | 555 | drm_dev_unregister(ddev); |
| 555 | 556 | |
| @@ -563,14 +564,14 @@ static int rcar_du_remove(struct platform_device *pdev) · 7 unmodified lines | ||
| 563 | 564 | static int rcar_du_probe(struct platform_device *pdev) |
| 564 | 565 | { |
| 565 | 566 | struct rcar_du_device *rcdu; |
| 566 | − struct drm_device *ddev; | |
| 567 | 567 | struct resource *mem; |
| 568 | 568 | int ret; |
| 569 | 569 | |
| 570 | 570 | /* Allocate and initialize the R-Car device structure. */ |
| 571 | − rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL); | |
| 572 | − if (rcdu == NULL) | |
| 573 | − return -ENOMEM; | |
| 571 | + rcdu = devm_drm_dev_alloc(&pdev->dev, &rcar_du_driver, | |
| 572 | + struct rcar_du_device, ddev); | |
| 573 | + if (IS_ERR(rcdu)) | |
| 574 | + return PTR_ERR(rcdu); | |
| 574 | 575 | |
| 575 | 576 | rcdu->dev = &pdev->dev; |
| 576 | 577 | rcdu->info = of_device_get_match_data(rcdu->dev); |
| @@ -584,13 +585,6 @@ static int rcar_du_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 584 | 585 | return PTR_ERR(rcdu->mmio); |
| 585 | 586 | |
| 586 | 587 | /* DRM/KMS objects */ |
| 587 | − ddev = drm_dev_alloc(&rcar_du_driver, &pdev->dev); | |
| 588 | − if (IS_ERR(ddev)) | |
| 589 | − return PTR_ERR(ddev); | |
| 590 | − | |
| 591 | − rcdu->ddev = ddev; | |
| 592 | − ddev->dev_private = rcdu; | |
| 593 | − | |
| 594 | 588 | ret = rcar_du_modeset_init(rcdu); |
| 595 | 589 | if (ret < 0) { |
| 596 | 590 | if (ret != -EPROBE_DEFER) |
| @@ -599,25 +593,24 @@ static int rcar_du_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 599 | 593 | goto error; |
| 600 | 594 | } |
| 601 | 595 | |
| 602 | − ddev->irq_enabled = 1; | |
| 596 | + rcdu->ddev.irq_enabled = 1; | |
| 603 | 597 | |
| 604 | 598 | /* |
| 605 | 599 | * Register the DRM device with the core and the connectors with |
| 606 | 600 | * sysfs. |
| 607 | 601 | */ |
| 608 | − ret = drm_dev_register(ddev, 0); | |
| 602 | + ret = drm_dev_register(&rcdu->ddev, 0); | |
| 609 | 603 | if (ret) |
| 610 | 604 | goto error; |
| 611 | 605 | |
| 612 | 606 | DRM_INFO("Device %s probed\n", dev_name(&pdev->dev)); |
| 613 | 607 | |
| 614 | − drm_fbdev_generic_setup(ddev, 32); | |
| 608 | + drm_fbdev_generic_setup(&rcdu->ddev, 32); | |
| 615 | 609 | |
| 616 | 610 | return 0; |
| 617 | 611 | |
| 618 | 612 | error: |
| 619 | − rcar_du_remove(pdev); | |
| 620 | − | |
| 613 | + drm_kms_helper_poll_fini(&rcdu->ddev); | |
| 621 | 614 | return ret; |
| 622 | 615 | } |
| 623 | 616 | |
| @@ -13,6 +13,8 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <linux/kernel.h> |
| 14 | 14 | #include <linux/wait.h> |
| 15 | 15 | |
| 16 | +#include <drm/drm_device.h> | |
| 17 | + | |
| 16 | 18 | #include "rcar_cmm.h" |
| 17 | 19 | #include "rcar_du_crtc.h" |
| 18 | 20 | #include "rcar_du_group.h" |
| @@ -20,10 +22,9 @@ · 1 unmodified line | ||
| 20 | 22 | |
| 21 | 23 | struct clk; |
| 22 | 24 | struct device; |
| 23 | −struct drm_device; | |
| 25 | +struct drm_bridge; | |
| 24 | 26 | struct drm_property; |
| 25 | 27 | struct rcar_du_device; |
| 26 | −struct rcar_du_encoder; | |
| 27 | 28 | |
| 28 | 29 | #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK BIT(0) /* Per-CRTC IRQ and clock */ |
| 29 | 30 | #define RCAR_DU_FEATURE_VSP1_SOURCE BIT(1) /* Has inputs from VSP1 */ |
| @@ -71,6 +72,7 @@ struct rcar_du_device_info { · 41 unmodified lines | ||
| 71 | 72 | #define RCAR_DU_MAX_CRTCS 4 |
| 72 | 73 | #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2) |
| 73 | 74 | #define RCAR_DU_MAX_VSPS 4 |
| 75 | +#define RCAR_DU_MAX_LVDS 2 | |
| 74 | 76 | |
| 75 | 77 | struct rcar_du_device { |
| 76 | 78 | struct device *dev; |
| @@ -78,16 +80,15 @@ struct rcar_du_device { · 1 unmodified line | ||
| 78 | 80 | |
| 79 | 81 | void __iomem *mmio; |
| 80 | 82 | |
| 81 | − struct drm_device *ddev; | |
| 83 | + struct drm_device ddev; | |
| 82 | 84 | |
| 83 | 85 | struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS]; |
| 84 | 86 | unsigned int num_crtcs; |
| 85 | 87 | |
| 86 | − struct rcar_du_encoder *encoders[RCAR_DU_OUTPUT_MAX]; | |
| 87 | − | |
| 88 | 88 | struct rcar_du_group groups[RCAR_DU_MAX_GROUPS]; |
| 89 | 89 | struct platform_device *cmms[RCAR_DU_MAX_CRTCS]; |
| 90 | 90 | struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS]; |
| 91 | + struct drm_bridge *lvds[RCAR_DU_MAX_LVDS]; | |
| 91 | 92 | |
| 92 | 93 | struct { |
| 93 | 94 | struct drm_property *colorkey; |
| @@ -98,6 +99,11 @@ struct rcar_du_device { · 4 unmodified lines | ||
| 98 | 99 | unsigned int vspd1_sink; |
| 99 | 100 | }; |
| 100 | 101 | |
| 102 | +static inline struct rcar_du_device *to_rcar_du_device(struct drm_device *dev) | |
| 103 | +{ | |
| 104 | + return container_of(dev, struct rcar_du_device, ddev); | |
| 105 | +} | |
| 106 | + | |
| 101 | 107 | static inline bool rcar_du_has(struct rcar_du_device *rcdu, |
| 102 | 108 | unsigned int feature) |
| 103 | 109 | { |
| @@ -8,12 +8,13 @@ · 7 unmodified lines | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | #include <linux/export.h> |
| 11 | +#include <linux/slab.h> | |
| 11 | 12 | |
| 12 | 13 | #include <drm/drm_bridge.h> |
| 13 | 14 | #include <drm/drm_crtc.h> |
| 15 | +#include <drm/drm_managed.h> | |
| 14 | 16 | #include <drm/drm_modeset_helper_vtables.h> |
| 15 | 17 | #include <drm/drm_panel.h> |
| 16 | −#include <drm/drm_simple_kms_helper.h> | |
| 17 | 18 | |
| 18 | 19 | #include "rcar_du_drv.h" |
| 19 | 20 | #include "rcar_du_encoder.h" |
| @@ -44,26 +45,25 @@ static unsigned int rcar_du_encoder_count_ports(struct device_node *node) · 24 unmodified lines | ||
| 44 | 45 | return num_ports; |
| 45 | 46 | } |
| 46 | 47 | |
| 48 | +static const struct drm_encoder_funcs rcar_du_encoder_funcs = { | |
| 49 | +}; | |
| 50 | + | |
| 51 | +static void rcar_du_encoder_release(struct drm_device *dev, void *res) | |
| 52 | +{ | |
| 53 | + struct rcar_du_encoder *renc = res; | |
| 54 | + | |
| 55 | + drm_encoder_cleanup(&renc->base); | |
| 56 | + kfree(renc); | |
| 57 | +} | |
| 58 | + | |
| 47 | 59 | int rcar_du_encoder_init(struct rcar_du_device *rcdu, |
| 48 | 60 | enum rcar_du_output output, |
| 49 | 61 | struct device_node *enc_node) |
| 50 | 62 | { |
| 51 | 63 | struct rcar_du_encoder *renc; |
| 52 | − struct drm_encoder *encoder; | |
| 53 | 64 | struct drm_bridge *bridge; |
| 54 | 65 | int ret; |
| 55 | 66 | |
| 56 | − renc = devm_kzalloc(rcdu->dev, sizeof(*renc), GFP_KERNEL); | |
| 57 | − if (renc == NULL) | |
| 58 | − return -ENOMEM; | |
| 59 | − | |
| 60 | − rcdu->encoders[output] = renc; | |
| 61 | − renc->output = output; | |
| 62 | − encoder = rcar_encoder_to_drm_encoder(renc); | |
| 63 | − | |
| 64 | − dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n", | |
| 65 | − enc_node, output); | |
| 66 | − | |
| 67 | 67 | /* |
| 68 | 68 | * Locate the DRM bridge from the DT node. For the DPAD outputs, if the |
| 69 | 69 | * DT node has a single port, assume that it describes a panel and |
| @@ -74,57 +74,57 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, · 4 unmodified lines | ||
| 74 | 74 | rcar_du_encoder_count_ports(enc_node) == 1) { |
| 75 | 75 | struct drm_panel *panel = of_drm_find_panel(enc_node); |
| 76 | 76 | |
| 77 | − if (IS_ERR(panel)) { | |
| 78 | − ret = PTR_ERR(panel); | |
| 79 | − goto done; | |
| 80 | − } | |
| 77 | + if (IS_ERR(panel)) | |
| 78 | + return PTR_ERR(panel); | |
| 81 | 79 | |
| 82 | 80 | bridge = devm_drm_panel_bridge_add_typed(rcdu->dev, panel, |
| 83 | 81 | DRM_MODE_CONNECTOR_DPI); |
| 84 | − if (IS_ERR(bridge)) { | |
| 85 | − ret = PTR_ERR(bridge); | |
| 86 | − goto done; | |
| 87 | − } | |
| 82 | + if (IS_ERR(bridge)) | |
| 83 | + return PTR_ERR(bridge); | |
| 88 | 84 | } else { |
| 89 | 85 | bridge = of_drm_find_bridge(enc_node); |
| 90 | − if (!bridge) { | |
| 91 | − ret = -EPROBE_DEFER; | |
| 92 | − goto done; | |
| 93 | − } | |
| 86 | + if (!bridge) | |
| 87 | + return -EPROBE_DEFER; | |
| 88 | + | |
| 89 | + if (output == RCAR_DU_OUTPUT_LVDS0 || | |
| 90 | + output == RCAR_DU_OUTPUT_LVDS1) | |
| 91 | + rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] = bridge; | |
| 94 | 92 | } |
| 95 | 93 | |
| 96 | 94 | /* |
| 97 | − * On Gen3 skip the LVDS1 output if the LVDS1 encoder is used as a | |
| 98 | − * companion for LVDS0 in dual-link mode. | |
| 95 | + * Create and initialize the encoder. On Gen3 skip the LVDS1 output if | |
| 96 | + * the LVDS1 encoder is used as a companion for LVDS0 in dual-link | |
| 97 | + * mode. | |
| 99 | 98 | */ |
| 100 | 99 | if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) { |
| 101 | − if (rcar_lvds_dual_link(bridge)) { | |
| 102 | − ret = -ENOLINK; | |
| 103 | − goto done; | |
| 104 | − } | |
| 100 | + if (rcar_lvds_dual_link(bridge)) | |
| 101 | + return -ENOLINK; | |
| 105 | 102 | } |
| 106 | 103 | |
| 107 | − ret = drm_simple_encoder_init(rcdu->ddev, encoder, | |
| 108 | − DRM_MODE_ENCODER_NONE); | |
| 109 | − if (ret < 0) | |
| 110 | − goto done; | |
| 104 | + renc = kzalloc(sizeof(*renc), GFP_KERNEL); | |
| 105 | + if (renc == NULL) | |
| 106 | + return -ENOMEM; | |
| 111 | 107 | |
| 112 | − /* | |
| 113 | − * Attach the bridge to the encoder. The bridge will create the | |
| 114 | − * connector. | |
| 115 | − */ | |
| 116 | − ret = drm_bridge_attach(encoder, bridge, NULL, 0); | |
| 117 | − if (ret) { | |
| 118 | − drm_encoder_cleanup(encoder); | |
| 119 | − return ret; | |
| 120 | − } | |
| 108 | + renc->output = output; | |
| 109 | + | |
| 110 | + dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n", | |
| 111 | + enc_node, output); | |
| 121 | 112 | |
| 122 | −done: | |
| 113 | + ret = drm_encoder_init(&rcdu->ddev, &renc->base, &rcar_du_encoder_funcs, | |
| 114 | + DRM_MODE_ENCODER_NONE, NULL); | |
| 123 | 115 | if (ret < 0) { |
| 124 | − if (encoder->name) | |
| 125 | − encoder->funcs->destroy(encoder); | |
| 126 | − devm_kfree(rcdu->dev, renc); | |
| 116 | + kfree(renc); | |
| 117 | + return ret; | |
| 127 | 118 | } |
| 128 | 119 | |
| 129 | − return ret; | |
| 120 | + ret = drmm_add_action_or_reset(&rcdu->ddev, rcar_du_encoder_release, | |
| 121 | + renc); | |
| 122 | + if (ret) | |
| 123 | + return ret; | |
| 124 | + | |
| 125 | + /* | |
| 126 | + * Attach the bridge to the encoder. The bridge will create the | |
| 127 | + * connector. | |
| 128 | + */ | |
| 129 | + return drm_bridge_attach(&renc->base, bridge, NULL, 0); | |
| 130 | 130 | } |
| @@ -22,8 +22,6 @@ struct rcar_du_encoder { · 21 unmodified lines | ||
| 22 | 22 | #define to_rcar_encoder(e) \ |
| 23 | 23 | container_of(e, struct rcar_du_encoder, base) |
| 24 | 24 | |
| 25 | −#define rcar_encoder_to_drm_encoder(e) (&(e)->base) | |
| 26 | − | |
| 27 | 25 | int rcar_du_encoder_init(struct rcar_du_device *rcdu, |
| 28 | 26 | enum rcar_du_output output, |
| 29 | 27 | struct device_node *enc_node); |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <drm/drm_fb_cma_helper.h> |
| 15 | 15 | #include <drm/drm_gem_cma_helper.h> |
| 16 | 16 | #include <drm/drm_gem_framebuffer_helper.h> |
| 17 | +#include <drm/drm_managed.h> | |
| 17 | 18 | #include <drm/drm_probe_helper.h> |
| 18 | 19 | #include <drm/drm_vblank.h> |
| 19 | 20 | |
| @@ -327,7 +328,7 @@ const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc) · 307 unmodified lines | ||
| 327 | 328 | int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, |
| 328 | 329 | struct drm_mode_create_dumb *args) |
| 329 | 330 | { |
| 330 | − struct rcar_du_device *rcdu = dev->dev_private; | |
| 331 | + struct rcar_du_device *rcdu = to_rcar_du_device(dev); | |
| 331 | 332 | unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); |
| 332 | 333 | unsigned int align; |
| 333 | 334 | |
| @@ -349,7 +350,7 @@ static struct drm_framebuffer * · 15 unmodified lines | ||
| 349 | 350 | rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, |
| 350 | 351 | const struct drm_mode_fb_cmd2 *mode_cmd) |
| 351 | 352 | { |
| 352 | − struct rcar_du_device *rcdu = dev->dev_private; | |
| 353 | + struct rcar_du_device *rcdu = to_rcar_du_device(dev); | |
| 353 | 354 | const struct rcar_du_format_info *format; |
| 354 | 355 | unsigned int chroma_pitch; |
| 355 | 356 | unsigned int max_pitch; |
| @@ -421,7 +422,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, · 65 unmodified lines | ||
| 421 | 422 | static int rcar_du_atomic_check(struct drm_device *dev, |
| 422 | 423 | struct drm_atomic_state *state) |
| 423 | 424 | { |
| 424 | − struct rcar_du_device *rcdu = dev->dev_private; | |
| 425 | + struct rcar_du_device *rcdu = to_rcar_du_device(dev); | |
| 425 | 426 | int ret; |
| 426 | 427 | |
| 427 | 428 | ret = drm_atomic_helper_check(dev, state); |
| @@ -437,7 +438,7 @@ static int rcar_du_atomic_check(struct drm_device *dev, · 9 unmodified lines | ||
| 437 | 438 | static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) |
| 438 | 439 | { |
| 439 | 440 | struct drm_device *dev = old_state->dev; |
| 440 | − struct rcar_du_device *rcdu = dev->dev_private; | |
| 441 | + struct rcar_du_device *rcdu = to_rcar_du_device(dev); | |
| 441 | 442 | struct drm_crtc_state *crtc_state; |
| 442 | 443 | struct drm_crtc *crtc; |
| 443 | 444 | unsigned int i; |
| @@ -583,7 +584,7 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu) · 139 unmodified lines | ||
| 583 | 584 | * or enable source color keying (1). |
| 584 | 585 | */ |
| 585 | 586 | rcdu->props.colorkey = |
| 586 | − drm_property_create_range(rcdu->ddev, 0, "colorkey", | |
| 587 | + drm_property_create_range(&rcdu->ddev, 0, "colorkey", | |
| 587 | 588 | 0, 0x01ffffff); |
| 588 | 589 | if (rcdu->props.colorkey == NULL) |
| 589 | 590 | return -ENOMEM; |
| @@ -700,10 +701,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu) · 110 unmodified lines | ||
| 700 | 701 | int ret; |
| 701 | 702 | |
| 702 | 703 | cmm = of_parse_phandle(np, "renesas,cmms", i); |
| 703 | − if (IS_ERR(cmm)) { | |
| 704 | + if (!cmm) { | |
| 704 | 705 | dev_err(rcdu->dev, |
| 705 | 706 | "Failed to parse 'renesas,cmms' property\n"); |
| 706 | − return PTR_ERR(cmm); | |
| 707 | + return -EINVAL; | |
| 707 | 708 | } |
| 708 | 709 | |
| 709 | 710 | if (!of_device_is_available(cmm)) { |
| @@ -713,10 +714,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu) · 3 unmodified lines | ||
| 713 | 714 | } |
| 714 | 715 | |
| 715 | 716 | pdev = of_find_device_by_node(cmm); |
| 716 | − if (IS_ERR(pdev)) { | |
| 717 | + if (!pdev) { | |
| 717 | 718 | dev_err(rcdu->dev, "No device found for CMM%u\n", i); |
| 718 | 719 | of_node_put(cmm); |
| 719 | − return PTR_ERR(pdev); | |
| 720 | + return -EINVAL; | |
| 720 | 721 | } |
| 721 | 722 | |
| 722 | 723 | of_node_put(cmm); |
| @@ -726,8 +727,12 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu) · 3 unmodified lines | ||
| 726 | 727 | * disabled: return 0 and let the DU continue probing. |
| 727 | 728 | */ |
| 728 | 729 | ret = rcar_cmm_init(pdev); |
| 729 | − if (ret) | |
| 730 | + if (ret) { | |
| 731 | + platform_device_put(pdev); | |
| 730 | 732 | return ret == -ENODEV ? 0 : ret; |
| 733 | + } | |
| 734 | + | |
| 735 | + rcdu->cmms[i] = pdev; | |
| 731 | 736 | |
| 732 | 737 | /* |
| 733 | 738 | * Enforce suspend/resume ordering by making the CMM a provider |
| @@ -739,20 +744,27 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu) · 5 unmodified lines | ||
| 739 | 744 | "Failed to create device link to CMM%u\n", i); |
| 740 | 745 | return -EINVAL; |
| 741 | 746 | } |
| 742 | − | |
| 743 | − rcdu->cmms[i] = pdev; | |
| 744 | 747 | } |
| 745 | 748 | |
| 746 | 749 | return 0; |
| 747 | 750 | } |
| 748 | 751 | |
| 752 | +static void rcar_du_modeset_cleanup(struct drm_device *dev, void *res) | |
| 753 | +{ | |
| 754 | + struct rcar_du_device *rcdu = to_rcar_du_device(dev); | |
| 755 | + unsigned int i; | |
| 756 | + | |
| 757 | + for (i = 0; i < ARRAY_SIZE(rcdu->cmms); ++i) | |
| 758 | + platform_device_put(rcdu->cmms[i]); | |
| 759 | +} | |
| 760 | + | |
| 749 | 761 | int rcar_du_modeset_init(struct rcar_du_device *rcdu) |
| 750 | 762 | { |
| 751 | 763 | static const unsigned int mmio_offsets[] = { |
| 752 | 764 | DU0_REG_OFFSET, DU2_REG_OFFSET |
| 753 | 765 | }; |
| 754 | 766 | |
| 755 | − struct drm_device *dev = rcdu->ddev; | |
| 767 | + struct drm_device *dev = &rcdu->ddev; | |
| 756 | 768 | struct drm_encoder *encoder; |
| 757 | 769 | unsigned int dpad0_sources; |
| 758 | 770 | unsigned int num_encoders; |
| @@ -766,6 +778,10 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) · 7 unmodified lines | ||
| 766 | 778 | if (ret) |
| 767 | 779 | return ret; |
| 768 | 780 | |
| 781 | + ret = drmm_add_action(&rcdu->ddev, rcar_du_modeset_cleanup, NULL); | |
| 782 | + if (ret) | |
| 783 | + return ret; | |
| 784 | + | |
| 769 | 785 | dev->mode_config.min_width = 0; |
| 770 | 786 | dev->mode_config.min_height = 0; |
| 771 | 787 | dev->mode_config.normalize_zpos = true; |
| @@ -128,7 +128,7 @@ static int rcar_du_plane_hwalloc(struct rcar_du_plane *plane, · 127 unmodified lines | ||
| 128 | 128 | int rcar_du_atomic_check_planes(struct drm_device *dev, |
| 129 | 129 | struct drm_atomic_state *state) |
| 130 | 130 | { |
| 131 | − struct rcar_du_device *rcdu = dev->dev_private; | |
| 131 | + struct rcar_du_device *rcdu = to_rcar_du_device(dev); | |
| 132 | 132 | unsigned int group_freed_planes[RCAR_DU_MAX_GROUPS] = { 0, }; |
| 133 | 133 | unsigned int group_free_planes[RCAR_DU_MAX_GROUPS] = { 0, }; |
| 134 | 134 | bool needs_realloc = false; |
| @@ -773,9 +773,9 @@ int rcar_du_planes_init(struct rcar_du_group *rgrp) · 638 unmodified lines | ||
| 773 | 773 | |
| 774 | 774 | plane->group = rgrp; |
| 775 | 775 | |
| 776 | − ret = drm_universal_plane_init(rcdu->ddev, &plane->plane, crtcs, | |
| 777 | − &rcar_du_plane_funcs, formats, | |
| 778 | − ARRAY_SIZE(formats), | |
| 776 | + ret = drm_universal_plane_init(&rcdu->ddev, &plane->plane, | |
| 777 | + crtcs, &rcar_du_plane_funcs, | |
| 778 | + formats, ARRAY_SIZE(formats), | |
| 779 | 779 | NULL, type, NULL); |
| 780 | 780 | if (ret < 0) |
| 781 | 781 | return ret; |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include <linux/dma-mapping.h> |
| 22 | 22 | #include <linux/of_platform.h> |
| 23 | 23 | #include <linux/scatterlist.h> |
| 24 | +#include <linux/slab.h> | |
| 24 | 25 | #include <linux/videodev2.h> |
| 25 | 26 | |
| 26 | 27 | #include <media/vsp1.h> |
| @@ -344,6 +345,15 @@ static const struct drm_plane_funcs rcar_du_vsp_plane_funcs = { · 317 unmodified lines | ||
| 344 | 345 | static void rcar_du_vsp_cleanup(struct drm_device *dev, void *res) |
| 345 | 346 | { |
| 346 | 347 | struct rcar_du_vsp *vsp = res; |
| 348 | + unsigned int i; | |
| 349 | + | |
| 350 | + for (i = 0; i < vsp->num_planes; ++i) { | |
| 351 | + struct rcar_du_vsp_plane *plane = &vsp->planes[i]; | |
| 352 | + | |
| 353 | + drm_plane_cleanup(&plane->plane); | |
| 354 | + } | |
| 355 | + | |
| 356 | + kfree(vsp->planes); | |
| 347 | 357 | |
| 348 | 358 | put_device(vsp->vsp); |
| 349 | 359 | } |
| @@ -354,6 +364,7 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, · 4 unmodified lines | ||
| 354 | 364 | struct rcar_du_device *rcdu = vsp->dev; |
| 355 | 365 | struct platform_device *pdev; |
| 356 | 366 | unsigned int num_crtcs = hweight32(crtcs); |
| 367 | + unsigned int num_planes; | |
| 357 | 368 | unsigned int i; |
| 358 | 369 | int ret; |
| 359 | 370 | |
| @@ -364,7 +375,7 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, · 4 unmodified lines | ||
| 364 | 375 | |
| 365 | 376 | vsp->vsp = &pdev->dev; |
| 366 | 377 | |
| 367 | − ret = drmm_add_action(rcdu->ddev, rcar_du_vsp_cleanup, vsp); | |
| 378 | + ret = drmm_add_action_or_reset(&rcdu->ddev, rcar_du_vsp_cleanup, vsp); | |
| 368 | 379 | if (ret < 0) |
| 369 | 380 | return ret; |
| 370 | 381 | |
| @@ -376,14 +387,13 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, · 5 unmodified lines | ||
| 376 | 387 | * The VSP2D (Gen3) has 5 RPFs, but the VSP1D (Gen2) is limited to |
| 377 | 388 | * 4 RPFs. |
| 378 | 389 | */ |
| 379 | − vsp->num_planes = rcdu->info->gen >= 3 ? 5 : 4; | |
| 390 | + num_planes = rcdu->info->gen >= 3 ? 5 : 4; | |
| 380 | 391 | |
| 381 | − vsp->planes = devm_kcalloc(rcdu->dev, vsp->num_planes, | |
| 382 | − sizeof(*vsp->planes), GFP_KERNEL); | |
| 392 | + vsp->planes = kcalloc(num_planes, sizeof(*vsp->planes), GFP_KERNEL); | |
| 383 | 393 | if (!vsp->planes) |
| 384 | 394 | return -ENOMEM; |
| 385 | 395 | |
| 386 | − for (i = 0; i < vsp->num_planes; ++i) { | |
| 396 | + for (i = 0; i < num_planes; ++i) { | |
| 387 | 397 | enum drm_plane_type type = i < num_crtcs |
| 388 | 398 | ? DRM_PLANE_TYPE_PRIMARY |
| 389 | 399 | : DRM_PLANE_TYPE_OVERLAY; |
| @@ -392,8 +402,8 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, · 2 unmodified lines | ||
| 392 | 402 | plane->vsp = vsp; |
| 393 | 403 | plane->index = i; |
| 394 | 404 | |
| 395 | − ret = drm_universal_plane_init(rcdu->ddev, &plane->plane, crtcs, | |
| 396 | − &rcar_du_vsp_plane_funcs, | |
| 405 | + ret = drm_universal_plane_init(&rcdu->ddev, &plane->plane, | |
| 406 | + crtcs, &rcar_du_vsp_plane_funcs, | |
| 397 | 407 | rcar_du_vsp_formats, |
| 398 | 408 | ARRAY_SIZE(rcar_du_vsp_formats), |
| 399 | 409 | NULL, type, NULL); |
| @@ -409,8 +419,10 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, · 9 unmodified lines | ||
| 409 | 419 | } else { |
| 410 | 420 | drm_plane_create_alpha_property(&plane->plane); |
| 411 | 421 | drm_plane_create_zpos_property(&plane->plane, 1, 1, |
| 412 | − vsp->num_planes - 1); | |
| 422 | + num_planes - 1); | |
| 413 | 423 | } |
| 424 | + | |
| 425 | + vsp->num_planes++; | |
| 414 | 426 | } |
| 415 | 427 | |
| 416 | 428 | return 0; |
| @@ -204,7 +204,7 @@ int rcar_du_writeback_init(struct rcar_du_device *rcdu, · 203 unmodified lines | ||
| 204 | 204 | drm_connector_helper_add(&wb_conn->base, |
| 205 | 205 | &rcar_du_wb_conn_helper_funcs); |
| 206 | 206 | |
| 207 | − return drm_writeback_connector_init(rcdu->ddev, wb_conn, | |
| 207 | + return drm_writeback_connector_init(&rcdu->ddev, wb_conn, | |
| 208 | 208 | &rcar_du_wb_conn_funcs, |
| 209 | 209 | &rcar_du_wb_enc_helper_funcs, |
| 210 | 210 | writeback_formats, |
| @@ -330,13 +330,6 @@ static const struct drm_plane_helper_funcs sti_cursor_helpers_funcs = { · 329 unmodified lines | ||
| 330 | 330 | .atomic_disable = sti_cursor_atomic_disable, |
| 331 | 331 | }; |
| 332 | 332 | |
| 333 | −static void sti_cursor_destroy(struct drm_plane *drm_plane) | |
| 334 | −{ | |
| 335 | − DRM_DEBUG_DRIVER("\n"); | |
| 336 | − | |
| 337 | − drm_plane_cleanup(drm_plane); | |
| 338 | −} | |
| 339 | − | |
| 340 | 333 | static int sti_cursor_late_register(struct drm_plane *drm_plane) |
| 341 | 334 | { |
| 342 | 335 | struct sti_plane *plane = to_sti_plane(drm_plane); |
| @@ -350,7 +343,7 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane) · 7 unmodified lines | ||
| 350 | 343 | static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = { |
| 351 | 344 | .update_plane = drm_atomic_helper_update_plane, |
| 352 | 345 | .disable_plane = drm_atomic_helper_disable_plane, |
| 353 | − .destroy = sti_cursor_destroy, | |
| 346 | + .destroy = drm_plane_cleanup, | |
| 354 | 347 | .reset = sti_plane_reset, |
| 355 | 348 | .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, |
| 356 | 349 | .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, |
| @@ -884,13 +884,6 @@ static const struct drm_plane_helper_funcs sti_gdp_helpers_funcs = { · 883 unmodified lines | ||
| 884 | 884 | .atomic_disable = sti_gdp_atomic_disable, |
| 885 | 885 | }; |
| 886 | 886 | |
| 887 | −static void sti_gdp_destroy(struct drm_plane *drm_plane) | |
| 888 | −{ | |
| 889 | − DRM_DEBUG_DRIVER("\n"); | |
| 890 | − | |
| 891 | − drm_plane_cleanup(drm_plane); | |
| 892 | −} | |
| 893 | − | |
| 894 | 887 | static int sti_gdp_late_register(struct drm_plane *drm_plane) |
| 895 | 888 | { |
| 896 | 889 | struct sti_plane *plane = to_sti_plane(drm_plane); |
| @@ -902,7 +895,7 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane) · 5 unmodified lines | ||
| 902 | 895 | static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = { |
| 903 | 896 | .update_plane = drm_atomic_helper_update_plane, |
| 904 | 897 | .disable_plane = drm_atomic_helper_disable_plane, |
| 905 | − .destroy = sti_gdp_destroy, | |
| 898 | + .destroy = drm_plane_cleanup, | |
| 906 | 899 | .reset = sti_plane_reset, |
| 907 | 900 | .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, |
| 908 | 901 | .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, |
| @@ -1262,13 +1262,6 @@ static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs = { · 1261 unmodified lines | ||
| 1262 | 1262 | .atomic_disable = sti_hqvdp_atomic_disable, |
| 1263 | 1263 | }; |
| 1264 | 1264 | |
| 1265 | −static void sti_hqvdp_destroy(struct drm_plane *drm_plane) | |
| 1266 | −{ | |
| 1267 | − DRM_DEBUG_DRIVER("\n"); | |
| 1268 | − | |
| 1269 | − drm_plane_cleanup(drm_plane); | |
| 1270 | −} | |
| 1271 | − | |
| 1272 | 1265 | static int sti_hqvdp_late_register(struct drm_plane *drm_plane) |
| 1273 | 1266 | { |
| 1274 | 1267 | struct sti_plane *plane = to_sti_plane(drm_plane); |
| @@ -1282,7 +1275,7 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane) · 7 unmodified lines | ||
| 1282 | 1275 | static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = { |
| 1283 | 1276 | .update_plane = drm_atomic_helper_update_plane, |
| 1284 | 1277 | .disable_plane = drm_atomic_helper_disable_plane, |
| 1285 | − .destroy = sti_hqvdp_destroy, | |
| 1278 | + .destroy = drm_plane_cleanup, | |
| 1286 | 1279 | .reset = sti_plane_reset, |
| 1287 | 1280 | .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, |
| 1288 | 1281 | .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, |
| @@ -56,7 +56,7 @@ static const struct file_operations tdfx_driver_fops = { · 55 unmodified lines | ||
| 56 | 56 | .llseek = noop_llseek, |
| 57 | 57 | }; |
| 58 | 58 | |
| 59 | −static struct drm_driver driver = { | |
| 59 | +static const struct drm_driver driver = { | |
| 60 | 60 | .driver_features = DRIVER_LEGACY, |
| 61 | 61 | .fops = &tdfx_driver_fops, |
| 62 | 62 | .name = DRIVER_NAME, |
| @@ -1268,11 +1268,6 @@ static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = { · 1267 unmodified lines | ||
| 1268 | 1268 | .atomic_async_update = vc4_plane_atomic_async_update, |
| 1269 | 1269 | }; |
| 1270 | 1270 | |
| 1271 | −static void vc4_plane_destroy(struct drm_plane *plane) | |
| 1272 | −{ | |
| 1273 | − drm_plane_cleanup(plane); | |
| 1274 | −} | |
| 1275 | − | |
| 1276 | 1271 | static bool vc4_format_mod_supported(struct drm_plane *plane, |
| 1277 | 1272 | uint32_t format, |
| 1278 | 1273 | uint64_t modifier) |
| @@ -1323,7 +1318,7 @@ static bool vc4_format_mod_supported(struct drm_plane *plane, · 44 unmodified lines | ||
| 1323 | 1318 | static const struct drm_plane_funcs vc4_plane_funcs = { |
| 1324 | 1319 | .update_plane = drm_atomic_helper_update_plane, |
| 1325 | 1320 | .disable_plane = drm_atomic_helper_disable_plane, |
| 1326 | − .destroy = vc4_plane_destroy, | |
| 1321 | + .destroy = drm_plane_cleanup, | |
| 1327 | 1322 | .set_property = NULL, |
| 1328 | 1323 | .reset = vc4_plane_reset, |
| 1329 | 1324 | .atomic_duplicate_state = vc4_plane_duplicate_state, |
| @@ -438,15 +438,10 @@ static const struct drm_plane_helper_funcs zx_gl_plane_helper_funcs = { · 437 unmodified lines | ||
| 438 | 438 | .atomic_disable = zx_plane_atomic_disable, |
| 439 | 439 | }; |
| 440 | 440 | |
| 441 | −static void zx_plane_destroy(struct drm_plane *plane) | |
| 442 | −{ | |
| 443 | − drm_plane_cleanup(plane); | |
| 444 | −} | |
| 445 | − | |
| 446 | 441 | static const struct drm_plane_funcs zx_plane_funcs = { |
| 447 | 442 | .update_plane = drm_atomic_helper_update_plane, |
| 448 | 443 | .disable_plane = drm_atomic_helper_disable_plane, |
| 449 | − .destroy = zx_plane_destroy, | |
| 444 | + .destroy = drm_plane_cleanup, | |
| 450 | 445 | .reset = drm_atomic_helper_plane_reset, |
| 451 | 446 | .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, |
| 452 | 447 | .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, |
| @@ -51,13 +51,6 @@ enum switch_power_state { · 50 unmodified lines | ||
| 51 | 51 | * may contain multiple heads. |
| 52 | 52 | */ |
| 53 | 53 | struct drm_device { |
| 54 | − /** | |
| 55 | − * @legacy_dev_list: | |
| 56 | − * | |
| 57 | − * List of devices per driver for stealth attach cleanup | |
| 58 | − */ | |
| 59 | − struct list_head legacy_dev_list; | |
| 60 | − | |
| 61 | 54 | /** @if_version: Highest interface version set */ |
| 62 | 55 | int if_version; |
| 63 | 56 | |
| @@ -83,11 +76,7 @@ struct drm_device { · 19 unmodified lines | ||
| 83 | 76 | } managed; |
| 84 | 77 | |
| 85 | 78 | /** @driver: DRM driver managing the device */ |
| 86 | −#ifdef CONFIG_DRM_LEGACY | |
| 87 | − struct drm_driver *driver; | |
| 88 | −#else | |
| 89 | 79 | const struct drm_driver *driver; |
| 90 | −#endif | |
| 91 | 80 | |
| 92 | 81 | /** |
| 93 | 82 | * @dev_private: |
| @@ -336,6 +325,9 @@ struct drm_device { · 242 unmodified lines | ||
| 336 | 325 | /* Everything below here is for legacy driver, never use! */ |
| 337 | 326 | /* private: */ |
| 338 | 327 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
| 328 | + /* List of devices per driver for stealth attach cleanup */ | |
| 329 | + struct list_head legacy_dev_list; | |
| 330 | + | |
| 339 | 331 | /* Context handle management - linked list of context handles */ |
| 340 | 332 | struct list_head ctxlist; |
| 341 | 333 | |
| @@ -499,8 +499,6 @@ struct drm_driver { · 498 unmodified lines | ||
| 499 | 499 | /* Everything below here is for legacy driver, never use! */ |
| 500 | 500 | /* private: */ |
| 501 | 501 | |
| 502 | − /* List of devices hanging off this driver with stealth attach. */ | |
| 503 | − struct list_head legacy_dev_list; | |
| 504 | 502 | int (*firstopen) (struct drm_device *); |
| 505 | 503 | void (*preclose) (struct drm_device *, struct drm_file *file_priv); |
| 506 | 504 | int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); |
| @@ -416,8 +416,5 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array, · 415 unmodified lines | ||
| 416 | 416 | bool write); |
| 417 | 417 | int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, |
| 418 | 418 | u32 handle, u64 *offset); |
| 419 | −int drm_gem_dumb_destroy(struct drm_file *file, | |
| 420 | − struct drm_device *dev, | |
| 421 | − uint32_t handle); | |
| 422 | 419 | |
| 423 | 420 | #endif /* __DRM_GEM_H__ */ |
| @@ -198,8 +198,10 @@ struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, · 197 unmodified lines | ||
| 198 | 198 | size_t align); |
| 199 | 199 | void drm_pci_free(struct drm_device *dev, struct drm_dma_handle *dmah); |
| 200 | 200 | |
| 201 | −int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); | |
| 202 | −void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); | |
| 201 | +int drm_legacy_pci_init(const struct drm_driver *driver, | |
| 202 | + struct pci_driver *pdriver); | |
| 203 | +void drm_legacy_pci_exit(const struct drm_driver *driver, | |
| 204 | + struct pci_driver *pdriver); | |
| 203 | 205 | |
| 204 | 206 | #else |
| 205 | 207 | |
| @@ -214,13 +216,13 @@ static inline void drm_pci_free(struct drm_device *dev, · 8 unmodified lines | ||
| 214 | 216 | { |
| 215 | 217 | } |
| 216 | 218 | |
| 217 | −static inline int drm_legacy_pci_init(struct drm_driver *driver, | |
| 219 | +static inline int drm_legacy_pci_init(const struct drm_driver *driver, | |
| 218 | 220 | struct pci_driver *pdriver) |
| 219 | 221 | { |
| 220 | 222 | return -EINVAL; |
| 221 | 223 | } |
| 222 | 224 | |
| 223 | −static inline void drm_legacy_pci_exit(struct drm_driver *driver, | |
| 225 | +static inline void drm_legacy_pci_exit(const struct drm_driver *driver, | |
| 224 | 226 | struct pci_driver *pdriver) |
| 225 | 227 | { |
| 226 | 228 | } |
| @@ -866,13 +866,19 @@ struct drm_connector_helper_funcs { · 865 unmodified lines | ||
| 866 | 866 | * The usual way to implement this is to cache the EDID retrieved in the |
| 867 | 867 | * probe callback somewhere in the driver-private connector structure. |
| 868 | 868 | * In this function drivers then parse the modes in the EDID and add |
| 869 | − * them by calling drm_add_edid_modes(). But connectors that driver a | |
| 869 | + * them by calling drm_add_edid_modes(). But connectors that drive a | |
| 870 | 870 | * fixed panel can also manually add specific modes using |
| 871 | 871 | * drm_mode_probed_add(). Drivers which manually add modes should also |
| 872 | 872 | * make sure that the &drm_connector.display_info, |
| 873 | 873 | * &drm_connector.width_mm and &drm_connector.height_mm fields are |
| 874 | 874 | * filled in. |
| 875 | 875 | * |
| 876 | + * Note that the caller function will automatically add standard VESA | |
| 877 | + * DMT modes up to 1024x768 if the .get_modes() helper operation returns | |
| 878 | + * no mode and if the connector status is connector_status_connected or | |
| 879 | + * connector_status_unknown. There is no need to call | |
| 880 | + * drm_add_modes_noedid() manually in that case. | |
| 881 | + * | |
| 876 | 882 | * Virtual drivers that just want some standard VESA mode with a given |
| 877 | 883 | * resolution can call drm_add_modes_noedid(), and mark the preferred |
| 878 | 884 | * one using drm_set_preferred_mode(). |