drm/vc4: Add support for the transposer IP
Subsystems (4)
v4 cover drm/vc4: Add support for the transposer IP
Hello,
This is the third version of this series adding writeback support to the VC4 display engine.
This version is based on drm-misc-next and include a bunch of modifications to the core that I had to add to make it work on VC4.
The only change in this v4 is a build failure fix in patch 3. See the changelog in each patch for more details.
Regards,
Boris
Boris Brezillon (8):
drm/atomic: Avoid connector to writeback_connector casts drm/connector: Pass a drm_connector_state to ->atomic_commit() drm/connector: Make ->atomic_commit() optional
drm/vc4: Use wait_for_flip_done() instead of wait_for_vblanks() drm/crtc: Add a generic infrastructure to fake VBLANK events drm/atomic: Call fake_vblank() from the generic commit_tail() helpers drm/vc4: Call drm_atomic_helper_fake_vblank() in the commit path drm/vc4: Add support for the transposer block
.../devicetree/bindings/display/brcm,bcm-vc4.txt | 6 + drivers/gpu/drm/drm_atomic.c | 4 +- drivers/gpu/drm/drm_atomic_helper.c | 47 +- drivers/gpu/drm/vc4/Makefile | 1 + drivers/gpu/drm/vc4/vc4_crtc.c | 138 ++++-- drivers/gpu/drm/vc4/vc4_debugfs.c | 1 + drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 7 + drivers/gpu/drm/vc4/vc4_kms.c | 11 +- drivers/gpu/drm/vc4/vc4_txp.c | 477 +++++++++++++++++++++ include/drm/drm_atomic_helper.h | 1 + include/drm/drm_crtc.h | 23 + include/drm/drm_modeset_helper_vtables.h | 6 +- include/drm/drm_writeback.h | 6 + 14 files changed, 693 insertions(+), 36 deletions(-) create mode 100644 drivers/gpu/drm/vc4/vc4_txp.c
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 1/8 drm/atomic: Avoid connector to writeback_connector casts
Use container_of() instead of type casting so that it keeps working even if base is moved inside the drm_writeback_connector struct.
---
Changes in v4:
- None
Changes in v3:
- Add Daniel's and Liviu's R-b
Changes in v2:
- New patch
--- drivers/gpu/drm/drm_atomic.c | 4 +++- include/drm/drm_writeback.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +3 -1
@@ -2423,6 +2423,7 @@ static int prepare_signaling(struct drm_device *dev, }for_each_new_connector_in_state (state, conn, conn_state, i) { +struct drm_writeback_connector *wb_conn;struct drm_writeback_job *job;struct drm_out_fence_state *f;struct dma_fence *fence;
@@ -2446,7 +2447,8 @@ static int prepare_signaling(struct drm_device *dev, f[*num_fences].out_fence_ptr = fence_ptr; *fence_state = f; - fence =drm_writeback_get_out_fence ((struct drm_writeback_connector *)conn); + wb_conn =drm_connector_to_writeback (conn); + fence =drm_writeback_get_out_fence (wb_conn);if (!fence)return -ENOMEM ;
include/drm/drm_writeback.h +6 -0
@@ -110,6 +110,12 @@ struct drm_writeback_job {struct dma_fence *out_fence; }; +static inline struct drm_writeback_connector * +drm_connector_to_writeback (struct drm_connector *connector) +{ + return container_of(connector, struct drm_writeback_connector, base); +} + int drm_writeback_connector_init(struct drm_device *dev, struct drm_writeback_connector *wb_connector, const struct drm_connector_funcs *con_funcs,
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 2/8 drm/connector: Pass a drm_connector_state to ->atomic_commit()
In reply to Boris BrezillonOther atomic hooks are passed state objects, let's change this one to be consistent.
---
Changes in v4:
- None
Changes in v3:
- Add Liviu's A-b and Daniel's R-b
Changes in v2:
- New patch
--- drivers/gpu/drm/drm_atomic_helper.c | 2 +- include/drm/drm_modeset_helper_vtables.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {WARN_ON (connector->connector_type !=DRM_MODE_CONNECTOR_WRITEBACK ); - funcs->atomic_commit (connector, new_conn_state->writeback_job); + funcs->atomic_commit (connector, new_conn_state); } } }
include/drm/drm_modeset_helper_vtables.h +3 -1
@@ -980,11 +980,13 @@ struct drm_connector_helper_funcs {* * This hook is to be used by drivers implementing writeback connectors * that need a point when to commit the writeback job to the hardware. +* The writeback_job to commit is available in +* &drm_connector_state.writeback_job. * * This callback is used by the atomic modeset helpers. */ void (*atomic_commit)(struct drm_connector *connector, -struct drm_writeback_job *writeback_job); +struct drm_connector_state *state); };/**
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 3/8 drm/connector: Make ->atomic_commit() optional
In reply to Boris BrezillonNot all writeback connector implementations might want to commit things from the connector driver. Some, like the malidp driver, commit things from their main commit_tail() function, and would rather not have to implement a dummy hook for drm_connector_helper_funcs.atomic_commit().
Make this function optional and reflect this fact in the doc.
---
Changes in v4:
- Add Liviu's ack
- Fix a build failure
Changes in v3:
- New patch
--- drivers/gpu/drm/drm_atomic_helper.c | 2 ++ include/drm/drm_modeset_helper_vtables.h | 2 ++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +2 -0
@@ -1184,6 +1184,8 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,const struct drm_connector_helper_funcs *funcs; funcs = connector->helper_private; +if (!funcs->atomic_commit) +continue ;if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {WARN_ON (connector->connector_type !=DRM_MODE_CONNECTOR_WRITEBACK );
include/drm/drm_modeset_helper_vtables.h +2 -0
@@ -983,6 +983,8 @@ struct drm_connector_helper_funcs {* The writeback_job to commit is available in * &drm_connector_state.writeback_job. * +* This hook is optional. +* * This callback is used by the atomic modeset helpers. */ void (*atomic_commit)(struct drm_connector *connector,
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 4/8 drm/vc4: Use wait_for_flip_done() instead of wait_for_vblanks()
In reply to Boris Brezillondrm_atomic_helper_wait_for_vblanks() assumes the CRTC will continuously generate VBLANK events and the vblank counter will keep increasing. While this work for a regular pipeline, it doesn't when you have the CRTC is feeding the transposer block, because this block works in oneshot mode, and, by the time we reach drm_atomic_helper_wait_for_vblanks() the only VBLANK event might have already been sent and the VBLANK counter will stay unchanged, thus triggering a timeout.
Luckily, we can replace the drm_atomic_helper_wait_for_vblanks() call by drm_atomic_helper_wait_for_flip_done() because the only thing we want to check when calling drm_atomic_helper_wait_for_vblanks() from vc4_atomic_complete_commit() is that new FBs are in use and the old ones can be safely released.
---
Changes in v4:
- None
Changes in v3:
- Add Eric's and Liviu's R-b
Changes in v2:
- None
--- drivers/gpu/drm/vc4/vc4_kms.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/vc4/vc4_kms.c +1 -10
@@ -153,18 +153,9 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)drm_atomic_helper_commit_modeset_enables (dev, state); -/* Make sure that drm_atomic_helper_wait_for_vblanks() -* actually waits for vblank. If we're doing a full atomic -* modeset (as opposed to a vc4_update_plane() short circuit), -* then we need to wait for scanout to be done with our -* display lists before we free it and potentially reallocate -* and overwrite the dlist memory with a new modeset. -*/ - state->legacy_cursor_update = false; -drm_atomic_helper_commit_hw_done (state); -drm_atomic_helper_wait_for_vblanks (dev, state); +drm_atomic_helper_wait_for_flip_done (dev, state);drm_atomic_helper_cleanup_planes (dev, state);
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 5/8 drm/crtc: Add a generic infrastructure to fake VBLANK events
In reply to Boris BrezillonIn some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.
In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.
---
Changes in v4:
- None
Changes in v3:
- Use inline doc for @no_vblank
- Fix drm_atomic_helper_fake_vblank() to only check new_crtc_state->no_vblank
- Add R-b tags
Changes in v2:
- New patch
--- drivers/gpu/drm/drm_atomic_helper.c | 39 +++++++++++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 1 + include/drm/drm_crtc.h | 23 ++++++++++++++++++++++ 3 files changed, 63 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +39 -0
@@ -2053,6 +2053,45 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state) }EXPORT_SYMBOL (drm_atomic_helper_wait_for_dependencies); +/** +* drm_atomic_helper_fake_vblank - fake VBLANK events if needed +* @old_state: atomic state object with old state structures +* +* This function walks all CRTCs and fake VBLANK events on those with +* &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL. +* The primary use of this function is writeback connectors working in oneshot +* mode and faking VBLANK events. In this case they only fake the VBLANK event +* when a job is queued, and any change to the pipeline that does not touch the +* connector is leading to timeouts when calling +* drm_atomic_helper_wait_for_vblanks() or +* drm_atomic_helper_wait_for_flip_done(). +* +* This is part of the atomic helper support for nonblocking commits, see +* drm_atomic_helper_setup_commit() for an overview. +*/ +void drm_atomic_helper_fake_vblank (struct drm_atomic_state *old_state) +{ +struct drm_crtc_state *new_crtc_state; +struct drm_crtc *crtc; +int i; + +for_each_new_crtc_in_state (old_state, crtc, new_crtc_state, i) { +unsigned long flags; + +if (!new_crtc_state->no_vblank) +continue ; + +spin_lock_irqsave (&old_state->dev->event_lock, flags); +if (new_crtc_state->event) { +drm_crtc_send_vblank_event (crtc, + new_crtc_state->event); + new_crtc_state->event =NULL ; + } +spin_unlock_irqrestore (&old_state->dev->event_lock, flags); + } +} +EXPORT_SYMBOL (drm_atomic_helper_fake_vblank); +/** * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit * @old_state: atomic state object with old state structures
include/drm/drm_atomic_helper.h +1 -0
@@ -100,6 +100,7 @@ int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,int drm_atomic_helper_setup_commit (struct drm_atomic_state *state,bool nonblock);void drm_atomic_helper_wait_for_dependencies (struct drm_atomic_state *state); +void drm_atomic_helper_fake_vblank (struct drm_atomic_state *state);void drm_atomic_helper_commit_hw_done (struct drm_atomic_state *state);void drm_atomic_helper_commit_cleanup_done (struct drm_atomic_state *state);
include/drm/drm_crtc.h +23 -0
@@ -119,6 +119,29 @@ struct drm_crtc_state { bool zpos_changed : 1; bool color_mgmt_changed : 1; +/** +* @no_vblank: +* +* Reflects the ability of a CRTC to send VBLANK events. This state +* usually depends on the pipeline configuration, and the main usuage +* is CRTCs feeding a writeback connector operating in oneshot mode. +* In this case the VBLANK event is only generated when a job is queued +* to the writeback connector, and we want the core to fake VBLANK +* events when this part of the pipeline hasn't changed but others had +* or when the CRTC and connectors are being disabled. +* +* __drm_atomic_helper_crtc_duplicate_state() will not reset the value +* from the current state, the CRTC driver is then responsible for +* updating this field when needed. +* +* Note that the combination of &drm_crtc_state.event == NULL and +* &drm_crtc_state.no_blank == true is valid and usually used when the +* writeback connector attached to the CRTC has a new job queued. In +* this case the driver will send the VBLANK event on its own when the +* writeback job is complete. +*/ + bool no_vblank : 1; +/* attached planes bitmask: * WARNING: transitional helpers do not maintain plane_mask so * drivers not converted over to atomic helpers should not rely
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 6/8 drm/atomic: Call fake_vblank() from the generic commit_tail() helpers
In reply to Boris BrezillonNow that we have a way to fake VBLANK events when requested by the CRTC hook it up to the generic commit_tail() helpers.
---
Changes in v4:
- None
Changes in v3:
- Add R-b tags
Changes in v2:
- New patch
--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
@@ -1450,6 +1450,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)drm_atomic_helper_commit_modeset_enables (dev, old_state); +drm_atomic_helper_fake_vblank (old_state); +drm_atomic_helper_commit_hw_done (old_state);drm_atomic_helper_wait_for_vblanks (dev, old_state);
@@ -1479,6 +1481,8 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)drm_atomic_helper_commit_planes (dev, old_state,DRM_PLANE_COMMIT_ACTIVE_ONLY ); +drm_atomic_helper_fake_vblank (old_state); +drm_atomic_helper_commit_hw_done (old_state);drm_atomic_helper_wait_for_vblanks (dev, old_state);
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 7/8 drm/vc4: Call drm_atomic_helper_fake_vblank() in the commit path
In reply to Boris BrezillonMimic what is done in drm_atomic_commit_tail() and call drm_atomic_helper_fake_vblank() so that VBLANK events are faked when the drm_crtc_state.no_vblank is true. Will be needed when we'll add support for the transposer block.
---
Changes in v4:
- None
Changes in v3:
- Add Eric's R-b
Changes in v2:
- New patch
--- drivers/gpu/drm/vc4/vc4_kms.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/vc4/vc4_kms.c +2 -0
@@ -153,6 +153,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)drm_atomic_helper_commit_modeset_enables (dev, state); +drm_atomic_helper_fake_vblank (state); +drm_atomic_helper_commit_hw_done (state);drm_atomic_helper_wait_for_flip_done (dev, state);
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 8/8 drm/vc4: Add support for the transposer block
In reply to Boris BrezillonFrom: Boris Brezillon <[email protected]>
The transposer block is providing support for mem-to-mem composition, which is exposed as a drm_writeback connector in DRM.
Add a driver to support this feature.
---
Changes in v4:
- Actually add Eric's R-b :-)
Changes in v3:
- Add Eric's R-b
- Fix the code updating ->no_blank so that it does not reset it to false when the CRTC is being disabled
- Use a table of txp formats instead of having a big switch-case block
- Fix typos in some comments
- Unconditionally update the DSP3 mux val
- Make sure we don't hang the system when TXP_BUSY is not cleared
Changes in v2:
- Rebased on top of drm-misc-next
--- .../devicetree/bindings/display/brcm,bcm-vc4.txt | 6 + drivers/gpu/drm/vc4/Makefile | 1 + drivers/gpu/drm/vc4/vc4_crtc.c | 138 ++++-- drivers/gpu/drm/vc4/vc4_debugfs.c | 1 + drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 7 + drivers/gpu/drm/vc4/vc4_txp.c | 477 +++++++++++++++++++++ 7 files changed, 607 insertions(+), 24 deletions(-) create mode 100644 drivers/gpu/drm/vc4/vc4_txp.c
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +6 -0
@@ -74,6 +74,12 @@ Required properties for DSI: The 3 clocks output from the DSI analog PHY: dsi[01]_byte, dsi[01]_ddr2, and dsi[01]_ddr +Required properties for the TXP (writeback) block: +- compatible: Should be "brcm,bcm2835-txp" +- reg: Physical base address and length of the TXP block's registers +- interrupts: The interrupt number + See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt + [1] Documentation/devicetree/bindings/media/video-interfaces.txt Example:
drivers/gpu/drm/vc4/Makefile +1 -0
@@ -19,6 +19,7 @@ vc4-y := \ vc4_plane.o \ vc4_render_cl.o \ vc4_trace_points.o \ + vc4_txp.o \ vc4_v3d.o \ vc4_validate.o \ vc4_validate_shaders.o
drivers/gpu/drm/vc4/vc4_crtc.c +114 -24
243 lines not on this page · raw message
drivers/gpu/drm/vc4/vc4_debugfs.c +1 -0
@@ -21,6 +21,7 @@ static const struct drm_info_list vc4_debugfs_list[] = { {"dsi1_regs", vc4_dsi_debugfs_regs, 0, (void *)(uintptr_t)1}, {"hdmi_regs", vc4_hdmi_debugfs_regs, 0}, {"vec_regs", vc4_vec_debugfs_regs, 0}, + {"txp_regs", vc4_txp_debugfs_regs, 0}, {"hvs_regs", vc4_hvs_debugfs_regs, 0}, {"crtc0_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)0}, {"crtc1_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)1},
drivers/gpu/drm/vc4/vc4_drv.c +1 -0
@@ -344,6 +344,7 @@ static struct platform_driver *const component_drivers[] = { &vc4_vec_driver, &vc4_dpi_driver, &vc4_dsi_driver, + &vc4_txp_driver, &vc4_hvs_driver, &vc4_crtc_driver, &vc4_v3d_driver,
drivers/gpu/drm/vc4/vc4_drv.h +7 -0
@@ -73,6 +73,7 @@ struct vc4_dev {struct vc4_dpi *dpi;struct vc4_dsi *dsi1;struct vc4_vec *vec; +struct vc4_txp *txp;struct vc4_hang_state *hang_state;
@@ -698,6 +699,8 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, bool in_vblank_irq, int *vpos, int *hpos, ktime_t *stime, ktime_t *etime, const struct drm_display_mode *mode); +void vc4_crtc_handle_vblank (struct vc4_crtc *crtc); +void vc4_crtc_txp_armed (struct drm_crtc_state *state);/* vc4_debugfs.c */ int vc4_debugfs_init (struct drm_minor *minor);
@@ -745,6 +748,10 @@ int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);extern struct platform_driver vc4_vec_driver;int vc4_vec_debugfs_regs (struct seq_file *m,void *unused); +/* vc4_txp.c */ +extern struct platform_driver vc4_txp_driver; +int vc4_txp_debugfs_regs (struct seq_file *m,void *unused); +/* vc4_irq.c */ irqreturn_t vc4_irq (int irq,void *arg);void vc4_irq_preinstall (struct drm_device *dev);
drivers/gpu/drm/vc4/vc4_txp.c new file +477 -0
477 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Boris Brezillon
AppliedQuoted 15 lines · On Tue, 3 Jul 2018 09:50:14 +0200 Boris Brezillon…
Hello,
This is the third version of this series adding writeback support to the VC4 display engine.
This version is based on drm-misc-next and include a bunch of modifications to the core that I had to add to make it work on VC4.
The only change in this v4 is a build failure fix in patch 3. See the changelog in each patch for more details.
Regards,
Boris
Quoted 9 lines
Boris Brezillon (8):
drm/atomic: Avoid connector towriteback_connectorcasts drm/connector: Pass adrm_connector_stateto ->atomic_commit() drm/connector: Make ->atomic_commit() optional
drm/vc4: Usewait_for_flip_done()instead ofwait_for_vblanks()drm/crtc: Add a generic infrastructure to fake VBLANK events drm/atomic: Callfake_vblank()from the genericcommit_tail()helpers drm/vc4: Calldrm_atomic_helper_fake_vblank()in the commit path drm/vc4: Add support for the transposer block
Applied to drm-misc-next.
Quoted 18 lines
.../devicetree/bindings/display/brcm,bcm-vc4.txt | 6 + drivers/gpu/drm/drm_atomic.c | 4 +- drivers/gpu/drm/drm_atomic_helper.c | 47 +- drivers/gpu/drm/vc4/Makefile | 1 + drivers/gpu/drm/vc4/vc4_crtc.c | 138 ++++-- drivers/gpu/drm/vc4/vc4_debugfs.c | 1 + drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 7 + drivers/gpu/drm/vc4/vc4_kms.c | 11 +- drivers/gpu/drm/vc4/vc4_txp.c | 477 +++++++++++++++++++++ include/drm/drm_atomic_helper.h | 1 + include/drm/drm_crtc.h | 23 + include/drm/drm_modeset_helper_vtables.h | 6 +- include/drm/drm_writeback.h | 6 + 14 files changed, 693 insertions(+), 36 deletions(-) create mode 100644 drivers/gpu/drm/vc4/vc4_txp.c
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel