staging: vboxvideo: Convert to atomic modesetting API
cover staging: vboxvideo: Convert to atomic modesetting API
Hi All,
This series converts the vboxvideo driver to the modesetting API, once this is merged I will submit a patch to move the driver out of staging and into drivers/gpu/drm.
This series consists of 3 parts:
1) More cleanups / prep work for atomic conversion
2) The actual atomic conversion, this is modelled after the atomic conversion of the qxl driver done by Gabriel Krisman Bertazi. Gabriel if you are reading this, thank you for providing a roadmap how to go about this.
3) Restore some features which were lost by the atomic conversion + more cleanups
Regards,
Hans
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH RESEND 1/15 staging: vboxvideo: Cleanup vbox_set_up_input_mapping()
This cleanups 2 things:
1) The first time we loop over the crtc-s, to compare framebuffers, fb1 may get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call to_vbox_framebuffer() on it. The result of this call is only used for an address comparison, so we don't end up dereferencing the bad pointer, but still it is better to not do this.
2) Since we already figure out the first crtc with a fb in the first loop and store that in fb1, there is no need to loop over the crtc-s again just to find the first crtc with a fb again.
--- drivers/staging/vboxvideo/vbox_mode.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/vboxvideo/vbox_mode.c +12 -12
@@ -169,7 +169,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) {struct drm_crtc *crtci;struct drm_connector *connectori; -struct drm_framebuffer *fb1 =NULL ; +struct drm_framebuffer *fb, *fb1 =NULL ;bool single_framebuffer = true;bool old_single_framebuffer = vbox->single_framebuffer;u16 width =0 , height =0 ;
@@ -180,25 +180,25 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)* Same fall-back if this is the fbdev frame-buffer. */ list_for_each_entry (crtci, &vbox->ddev.mode_config.crtc_list, head) { + fb =CRTC_FB (crtci); +if (!fb) +continue ; +if (!fb1) { - fb1 =CRTC_FB (crtci); + fb1 = fb;if (to_vbox_framebuffer (fb1) == &vbox->fbdev->afb)break ; - }else if (CRTC_FB (crtci) && fb1 !=CRTC_FB (crtci)) { + }else if (fb != fb1) { single_framebuffer = false; } } +if (!fb1) +return false; +if (single_framebuffer) { vbox->single_framebuffer = true; -list_for_each_entry (crtci, &vbox->ddev.mode_config.crtc_list, - head) { -if (!CRTC_FB (crtci)) -continue ; - - vbox->input_mapping_width =CRTC_FB (crtci)->width; - vbox->input_mapping_height =CRTC_FB (crtci)->height; -break ; - } + vbox->input_mapping_width = fb1->width; + vbox->input_mapping_height = fb1->height;return old_single_framebuffer != vbox->single_framebuffer; }/* Otherwise calculate the total span of all screens. */
Signature · 1 line
2.19.0
PATCH RESEND 2/15 staging: vboxvideo: Remove empty encoder_helper_funcs
In reply to Hans de GoedeAll the encoder_helper_funcs are optional, and even setting the drm_encoder_helper_funcs vtable itself is optional and may be left out when not using any of the helper funcs, so lets drop all of this.
--- drivers/staging/vboxvideo/vbox_mode.c | 34 --------------------------- 1 file changed, 34 deletions(-)
drivers/staging/vboxvideo/vbox_mode.c +0 -34
@@ -466,39 +466,6 @@ static const struct drm_encoder_funcs vbox_enc_funcs = { .destroy = vbox_encoder_destroy, }; -static void vbox_encoder_dpms (struct drm_encoder *encoder,int mode) -{ -} - -static bool vbox_mode_fixup (struct drm_encoder *encoder, -const struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode) -{ -return true; -} - -static void vbox_encoder_mode_set (struct drm_encoder *encoder, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode) -{ -} - -static void vbox_encoder_prepare (struct drm_encoder *encoder) -{ -} - -static void vbox_encoder_commit (struct drm_encoder *encoder) -{ -} - -static const struct drm_encoder_helper_funcs vbox_enc_helper_funcs = { - .dpms = vbox_encoder_dpms, - .mode_fixup = vbox_mode_fixup, - .prepare = vbox_encoder_prepare, - .commit = vbox_encoder_commit, - .mode_set = vbox_encoder_mode_set, -}; -static struct drm_encoder *vbox_encoder_init (struct drm_device *dev,unsigned int i) {
@@ -510,7 +477,6 @@ static struct drm_encoder *vbox_encoder_init(struct drm_device *dev,drm_encoder_init (dev, &vbox_encoder->base, &vbox_enc_funcs,DRM_MODE_ENCODER_DAC ,NULL ); -drm_encoder_helper_add (&vbox_encoder->base, &vbox_enc_helper_funcs); vbox_encoder->base.possible_crtcs =1 << i;return &vbox_encoder->base;
Signature · 6 lines
2.19.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH RESEND 3/15 staging: vboxvideo: Temporarily remove page_flip support
In reply to Hans de Goededrm_mode_page_flip_ioctl() cannot deal with the in between phase of the transitioning to atomic modeset support. Once we start using drm_helper_crtc_mode_set(), we start setting plane->state on the primary plane. But we are not fully atomic yet so then set both plane-state->fb and plane->fb.
If both plane-state->fb and plane->fb are set drm_mode_page_flip_ioctl() gets confused and stops calling drm_framebuffer_get() on the new fb while still calling drm_framebuffer_put() on the old fb.
The current page_flip implementation expects drm_mode_page_flip_ioctl() to take care of both and once we switch to drm_atomic_helper_page_flip() that will expect neither to be done, taking care of both itself.
So for the transition we need to remove page_flip support and then after the transition is complete and we set DRIVER_ATOMIC in our driver_features, we can start using drm_atomic_helper_page_flip().
--- drivers/staging/vboxvideo/vbox_mode.c | 35 --------------------------- 1 file changed, 35 deletions(-)
drivers/staging/vboxvideo/vbox_mode.c +0 -35
@@ -282,40 +282,6 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,return 0 ; } -static int vbox_crtc_page_flip (struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_pending_vblank_event *event, -uint32_t page_flip_flags, -struct drm_modeset_acquire_ctx *ctx) -{ -struct vbox_bo *bo =gem_to_vbox_bo (to_vbox_framebuffer (fb)->obj); -struct drm_framebuffer *old_fb =CRTC_FB (crtc); -unsigned long flags; -int rc; - - rc =vbox_bo_pin (bo,TTM_PL_FLAG_VRAM ); -if (rc) { -DRM_WARN ("Error %d pinning new fb, out of video mem?\n" , rc); -return rc; - } - -vbox_crtc_set_base_and_mode (crtc, fb,NULL ,0 ,0 ); - -if (old_fb) { - bo =gem_to_vbox_bo (to_vbox_framebuffer (old_fb)->obj); -vbox_bo_unpin (bo); - } - -spin_lock_irqsave (&crtc->dev->event_lock, flags); - -if (event) -drm_crtc_send_vblank_event (crtc, event); - -spin_unlock_irqrestore (&crtc->dev->event_lock, flags); - -return 0 ; -} -static void vbox_crtc_disable (struct drm_crtc *crtc) { }
@@ -353,7 +319,6 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = { .reset = vbox_crtc_reset, .set_config = drm_crtc_helper_set_config, /* .gamma_set = vbox_crtc_gamma_set, */ - .page_flip = vbox_crtc_page_flip, .destroy = vbox_crtc_destroy, };
Signature · 6 lines
2.19.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH RESEND 4/15 staging: vboxvideo: Cache mode width, height and crtc panning in vbox_crtc
In reply to Hans de GoedeWhen setting a mode we not only pass the mode to the hypervisor, but also information on how to map / translate input coordinates for the emulated USB tablet. This input-mapping may change when the mode on *another* crtc changes.
This means that sometimes we must do a modeset on other crtc-s then the one being changed to update the input-mapping. Including crtc-s which may be disabled inside the guest (shown as a black window on the host unless closed by the user).
With atomic modesetting the mode-info of disabled crtcs gets zeroed yet we need it when updating the input-map to avoid resizing the window as a side effect of a mode_set on another crtc.
This commit adds caching of the mode info into out private vbox_crtc struct so that we always have the info at hand when we need it.
--- drivers/staging/vboxvideo/vbox_drv.h | 20 +++++++++++++++++++ drivers/staging/vboxvideo/vbox_mode.c | 28 +++++++++++++++------------ 2 files changed, 36 insertions(+), 12 deletions(-)
drivers/staging/vboxvideo/vbox_drv.h +20 -0
@@ -151,6 +151,26 @@ struct vbox_crtc {bool cursor_enabled;u32 x_hint;u32 y_hint; +/* +* When setting a mode we not only pass the mode to the hypervisor, +* but also information on how to map / translate input coordinates +* for the emulated USB tablet. This input-mapping may change when +* the mode on *another* crtc changes. +* +* This means that sometimes we must do a modeset on other crtc-s then +* the one being changed to update the input-mapping. Including crtc-s +* which may be disabled inside the guest (shown as a black window +* on the host unless closed by the user). +* +* With atomic modesetting the mode-info of disabled crtcs gets zeroed +* yet we need it when updating the input-map to avoid resizing the +* window as a side effect of a mode_set on another crtc. Therefor we +* cache the info of the last mode below. +*/ +u32 width; +u32 height; +u32 x; +u32 y; };struct vbox_encoder {
drivers/staging/vboxvideo/vbox_mode.c +16 -12
@@ -48,8 +48,7 @@ static int vbox_cursor_move(struct drm_crtc *crtc, int x, int y);* Set a graphics mode. Poke any required values into registers, do an HGSMI * mode set and tell the host we support advanced graphics functions. */ -static void vbox_do_modeset (struct drm_crtc *crtc, -const struct drm_display_mode *mode) +static void vbox_do_modeset (struct drm_crtc *crtc) {struct vbox_crtc *vbox_crtc =to_vbox_crtc (crtc);struct vbox_private *vbox;
@@ -58,12 +57,12 @@ static void vbox_do_modeset(struct drm_crtc *crtc,s32 x_offset, y_offset; vbox = crtc->dev->dev_private; - width = mode->hdisplay ? mode->hdisplay :640 ; - height = mode->vdisplay ? mode->vdisplay :480 ; + width = vbox_crtc->width ? vbox_crtc->width :640 ; + height = vbox_crtc->height ? vbox_crtc->height :480 ; bpp = crtc->enabled ?CRTC_FB (crtc)->format->cpp[0 ] *8 :32 ; pitch = crtc->enabled ?CRTC_FB (crtc)->pitches[0 ] : width * bpp /8 ; - x_offset = vbox->single_framebuffer ? crtc->x : vbox_crtc->x_hint; - y_offset = vbox->single_framebuffer ? crtc->y : vbox_crtc->y_hint; + x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint; + y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;/* * This is the old way of setting graphics modes. It assumed one screen
@@ -82,9 +81,9 @@ static void vbox_do_modeset(struct drm_crtc *crtc,vbox_write_ioport (VBE_DISPI_INDEX_ENABLE ,VBE_DISPI_ENABLED );vbox_write_ioport (VBE_DISPI_INDEX_X_OFFSET , - vbox_crtc->fb_offset % pitch / bpp *8 + crtc->x); + vbox_crtc->fb_offset % pitch / bpp *8 + vbox_crtc->x);vbox_write_ioport (VBE_DISPI_INDEX_Y_OFFSET , - vbox_crtc->fb_offset / pitch + crtc->y); + vbox_crtc->fb_offset / pitch + vbox_crtc->y); } flags =VBVA_SCREEN_F_ACTIVE ;
@@ -93,7 +92,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc, flags |= vbox_crtc->disconnected ?VBVA_SCREEN_F_DISABLED :0 ;hgsmi_process_display_info (vbox->guest_pool, vbox_crtc->crtc_id, x_offset, y_offset, - crtc->x * bpp /8 + crtc->y * pitch, + vbox_crtc->x * bpp /8 + + vbox_crtc->y * pitch, pitch, width, height, vbox_crtc->blanked ?0 : bpp, flags); }
@@ -149,7 +149,7 @@ static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode) }mutex_lock (&vbox->hw_mutex); -vbox_do_modeset (crtc, &crtc->hwmode); +vbox_do_modeset (crtc);mutex_unlock (&vbox->hw_mutex); }
@@ -232,6 +232,10 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,mutex_lock (&vbox->hw_mutex); + vbox_crtc->width = mode->hdisplay; + vbox_crtc->height = mode->vdisplay; + vbox_crtc->x = x; + vbox_crtc->y = y; vbox_crtc->fb_offset =vbox_bo_gpu_offset (bo);/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
@@ -242,12 +246,12 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, head) {if (crtci == crtc)continue ; -vbox_do_modeset (crtci, &crtci->mode); +vbox_do_modeset (crtci); } }vbox_set_view (crtc); -vbox_do_modeset (crtc, mode ? mode : &crtc->mode); +vbox_do_modeset (crtc);if (mode) hgsmi_update_input_mapping(vbox->guest_pool, 0, 0,
Signature · 6 lines
2.19.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH RESEND 5/15 staging: vboxvideo: Atomic phase 1: convert cursor to universal plane
In reply to Hans de GoedeIn preparation for atomic conversion, let's use the transitional atomic helpers drm_plane_helper_update/disable.
--- drivers/staging/vboxvideo/vbox_drv.h | 5 - drivers/staging/vboxvideo/vbox_mode.c | 386 +++++++++++++------------- 2 files changed, 186 insertions(+), 205 deletions(-)
drivers/staging/vboxvideo/vbox_drv.h +0 -5
@@ -116,11 +116,6 @@ struct vbox_private {* encompassing all screen ones or is the fbdev console active? */ bool single_framebuffer; -u32 cursor_width; -u32 cursor_height; -u32 cursor_hot_x; -u32 cursor_hot_y; -size_t cursor_data_size;u8 cursor_data[CURSOR_DATA_SIZE ]; };
drivers/staging/vboxvideo/vbox_mode.c +186 -200
455 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH RESEND 6/15 staging: vboxvideo: Atomic phase 1: Use drm_plane_helpers for primary plane
In reply to Hans de GoedeUse drm_plane_helpers for the primary plane and replace our custom mode_set callback with drm_helper_crtc_mode_set.
--- drivers/staging/vboxvideo/vbox_mode.c | 116 ++++++++++++++++++++------ 1 file changed, 90 insertions(+), 26 deletions(-)
drivers/staging/vboxvideo/vbox_mode.c +90 -26
@@ -257,50 +257,48 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,mutex_unlock (&vbox->hw_mutex); } -static int vbox_crtc_mode_set (struct drm_crtc *crtc, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode, -int x,int y,struct drm_framebuffer *old_fb) +static void vbox_crtc_disable (struct drm_crtc *crtc) { -struct drm_framebuffer *new_fb =CRTC_FB (crtc); -struct vbox_bo *bo =gem_to_vbox_bo (to_vbox_framebuffer (new_fb)->obj); -int ret; - - ret =vbox_bo_pin (bo,TTM_PL_FLAG_VRAM ); -if (ret) { -DRM_WARN ("Error %d pinning new fb, out of video mem?\n" , ret); -return ret; - } - -vbox_crtc_set_base_and_mode (crtc, new_fb, mode, x, y); - -if (old_fb) { - bo =gem_to_vbox_bo (to_vbox_framebuffer (old_fb)->obj); -vbox_bo_unpin (bo); - } +} -return 0 ; +static void vbox_crtc_prepare (struct drm_crtc *crtc) +{ } -static void vbox_crtc_disable (struct drm_crtc *crtc) +static void vbox_crtc_commit (struct drm_crtc *crtc) { } -static void vbox_crtc_prepare (struct drm_crtc *crtc) +static void vbox_crtc_mode_set_nofb (struct drm_crtc *crtc) { +/* We always set the mode when we set the fb/base */ } -static void vbox_crtc_commit (struct drm_crtc *crtc) +static void vbox_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) { +struct drm_pending_vblank_event *event; +unsigned long flags; + +if (crtc->state && crtc->state->event) { + event = crtc->state->event; + crtc->state->event =NULL ; + +spin_lock_irqsave (&crtc->dev->event_lock, flags); +drm_crtc_send_vblank_event (crtc, event); +spin_unlock_irqrestore (&crtc->dev->event_lock, flags); + } }static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = { .dpms = vbox_crtc_dpms, .mode_fixup = vbox_crtc_mode_fixup, - .mode_set = vbox_crtc_mode_set, + .mode_set = drm_helper_crtc_mode_set, + .mode_set_nofb = vbox_crtc_mode_set_nofb, .disable = vbox_crtc_disable, .prepare = vbox_crtc_prepare, .commit = vbox_crtc_commit, + .atomic_flush = vbox_crtc_atomic_flush, };static void vbox_crtc_reset (struct drm_crtc *crtc)
@@ -320,6 +318,63 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = { .destroy = vbox_crtc_destroy, }; +static int vbox_primary_atomic_check (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ +return 0 ; +} + +static void vbox_primary_atomic_update (struct drm_plane *plane, +struct drm_plane_state *old_state) +{ +struct drm_crtc *crtc = plane->state->crtc; +struct drm_framebuffer *fb = plane->state->fb; + +vbox_crtc_set_base_and_mode (crtc, fb, &crtc->state->mode, + plane->state->src_x >>16 , + plane->state->src_y >>16 ); +} + +void vbox_primary_atomic_disable (struct drm_plane *plane, +struct drm_plane_state *old_state) +{ +struct drm_crtc *crtc = old_state->crtc; + +/* vbox_do_modeset checks plane->state->fb and will disable if NULL */ +vbox_crtc_set_base_and_mode (crtc, old_state->fb, &crtc->state->mode, + old_state->src_x >>16 , + old_state->src_y >>16 ); +} + +static int vbox_primary_prepare_fb (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ +struct vbox_bo *bo; +int ret; + +if (!new_state->fb) +return 0 ; + + bo =gem_to_vbox_bo (to_vbox_framebuffer (new_state->fb)->obj); + ret =vbox_bo_pin (bo,TTM_PL_FLAG_VRAM ); +if (ret) +DRM_WARN ("Error %d pinning new fb, out of video mem?\n" , ret); + +return ret; +} + +static void vbox_primary_cleanup_fb (struct drm_plane *plane, +struct drm_plane_state *old_state) +{ +struct vbox_bo *bo; + +if (!old_state->fb) +return ; + + bo =gem_to_vbox_bo (to_vbox_framebuffer (old_state->fb)->obj); +vbox_bo_unpin (bo); +} +static int vbox_cursor_atomic_check (struct drm_plane *plane,struct drm_plane_state *new_state) {
@@ -479,8 +534,16 @@ static const uint32_t vbox_primary_plane_formats[] = { DRM_FORMAT_ARGB8888, }; +static const struct drm_plane_helper_funcs vbox_primary_helper_funcs = { + .atomic_check = vbox_primary_atomic_check, + .atomic_update = vbox_primary_atomic_update, + .atomic_disable = vbox_primary_atomic_disable, + .prepare_fb = vbox_primary_prepare_fb, + .cleanup_fb = vbox_primary_cleanup_fb, +}; +static const struct drm_plane_funcs vbox_primary_plane_funcs = { - .update_plane = drm_primary_helper_update, + .update_plane = drm_plane_helper_update, .disable_plane = drm_primary_helper_disable, .destroy = drm_primary_helper_destroy, };
@@ -499,6 +562,7 @@ static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,if (type ==DRM_PLANE_TYPE_PRIMARY ) { funcs = &vbox_primary_plane_funcs; formats = vbox_primary_plane_formats; + helper_funcs = &vbox_primary_helper_funcs; num_formats =ARRAY_SIZE (vbox_primary_plane_formats); }else if (type ==DRM_PLANE_TYPE_CURSOR ) { funcs = &vbox_cursor_plane_funcs;
Signature · 1 line
2.19.0
PATCH RESEND 7/15 staging: vboxvideo: Atomic phase 2: Wire up state object handlers
In reply to Hans de GoedeWire up state object handlers for the crtc-s and the planes, call drm_mode_config_reset() after creating all the crtc-s and encoders and remove the legacy drm_helper_disable_unused_functions() call.
--- drivers/staging/vboxvideo/vbox_fb.c | 3 --- drivers/staging/vboxvideo/vbox_mode.c | 15 ++++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/staging/vboxvideo/vbox_fb.c +0 -3
@@ -216,9 +216,6 @@ int vbox_fbdev_init(struct vbox_private *vbox)if (ret) goto err_fini; -/* disable all the possible outputs/crtcs before entering KMS mode */ -drm_helper_disable_unused_functions (dev); - ret =drm_fb_helper_initial_config (&fbdev->helper,32 );if (ret) goto err_fini;
drivers/staging/vboxvideo/vbox_mode.c +10 -5
@@ -301,10 +301,6 @@ static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = { .atomic_flush = vbox_crtc_atomic_flush, }; -static void vbox_crtc_reset (struct drm_crtc *crtc) -{ -} -static void vbox_crtc_destroy (struct drm_crtc *crtc) {drm_crtc_cleanup (crtc);
@@ -312,10 +308,12 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc) }static const struct drm_crtc_funcs vbox_crtc_funcs = { - .reset = vbox_crtc_reset, .set_config = drm_crtc_helper_set_config,/* .gamma_set = vbox_crtc_gamma_set, */ .destroy = vbox_crtc_destroy, + .reset = drm_atomic_helper_crtc_reset, + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, }; static int vbox_primary_atomic_check(struct drm_plane *plane,
@@ -527,6 +525,9 @@ static const struct drm_plane_funcs vbox_cursor_plane_funcs = { .update_plane = drm_plane_helper_update, .disable_plane = drm_plane_helper_disable, .destroy = drm_primary_helper_destroy, + .reset = drm_atomic_helper_plane_reset, + .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, };static const uint32_t vbox_primary_plane_formats[] = {
@@ -546,6 +547,9 @@ static const struct drm_plane_funcs vbox_primary_plane_funcs = { .update_plane = drm_plane_helper_update, .disable_plane = drm_primary_helper_disable, .destroy = drm_primary_helper_destroy, + .reset = drm_atomic_helper_plane_reset, + .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,
@@ -982,6 +986,7 @@ int vbox_mode_init(struct vbox_private *vbox) goto err_drm_mode_cleanup; } +drm_mode_config_reset (dev);return 0 ; err_drm_mode_cleanup:
Signature · 1 line
2.19.0
PATCH RESEND 8/15 staging: vboxvideo: Atomic phase 2: Stop using plane->fb and crtc->*
In reply to Hans de GoedeOnce we are fully atomic plane->fb will always be NULL and we also should not access things like crtc->enabled and crt->[hw]mode.
Now that we've wired up the state object handlers, we always have a plane_state and crtc_state so change the code referencing plane->fb and crtc->* to use the data from the plane_state and crt_state instead.
--- drivers/staging/vboxvideo/vbox_drv.h | 1 - drivers/staging/vboxvideo/vbox_main.c | 16 +++++++++++----- drivers/staging/vboxvideo/vbox_mode.c | 15 +++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-)
drivers/staging/vboxvideo/vbox_drv.h +0 -1
@@ -199,7 +199,6 @@ int vbox_mode_init(struct vbox_private *vbox);void vbox_mode_fini (struct vbox_private *vbox);#define DRM_MODE_FB_CMD drm_mode_fb_cmd2 -#define CRTC_FB (crtc) ((crtc)->primary->fb)void vbox_enable_accel (struct vbox_private *vbox);void vbox_disable_accel (struct vbox_private *vbox);
drivers/staging/vboxvideo/vbox_main.c +11 -5
@@ -102,24 +102,30 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, unsigned int num_rects) {struct vbox_private *vbox = fb->dev->dev_private; +struct drm_display_mode *mode;struct drm_crtc *crtc; +int crtc_x, crtc_y;unsigned int i;mutex_lock (&vbox->hw_mutex);list_for_each_entry (crtc, &fb->dev->mode_config.crtc_list, head) { -if (CRTC_FB (crtc) != fb) +if (crtc->primary->state->fb != fb)continue ; + mode = &crtc->state->mode; + crtc_x = crtc->primary->state->src_x >>16 ; + crtc_y = crtc->primary->state->src_y >>16 ; +vbox_enable_accel (vbox);for (i =0 ; i < num_rects; ++i) {struct vbva_cmd_hdr cmd_hdr;unsigned int crtc_id =to_vbox_crtc (crtc)->crtc_id; -if ((rects[i].x1 > crtc->x + crtc->hwmode.hdisplay) || - (rects[i].y1 > crtc->y + crtc->hwmode.vdisplay) || - (rects[i].x2 < crtc->x) || - (rects[i].y2 < crtc->y)) +if ((rects[i].x1 > crtc_x + mode->hdisplay) || + (rects[i].y1 > crtc_y + mode->vdisplay) || + (rects[i].x2 < crtc_x) || + (rects[i].y2 < crtc_y))continue ; cmd_hdr.x = (s16 )rects[i].x1;
drivers/staging/vboxvideo/vbox_mode.c +7 -8
@@ -46,6 +46,7 @@*/ static void vbox_do_modeset (struct drm_crtc *crtc) { +struct drm_framebuffer *fb = crtc->primary->state->fb;struct vbox_crtc *vbox_crtc =to_vbox_crtc (crtc);struct vbox_private *vbox;int width, height, bpp, pitch;
@@ -55,8 +56,8 @@ static void vbox_do_modeset(struct drm_crtc *crtc) vbox = crtc->dev->dev_private; width = vbox_crtc->width ? vbox_crtc->width :640 ; height = vbox_crtc->height ? vbox_crtc->height :480 ; - bpp = crtc->enabled ?CRTC_FB (crtc)->format->cpp[0 ] *8 :32 ; - pitch = crtc->enabled ?CRTC_FB (crtc)->pitches[0 ] : width * bpp /8 ; + bpp = fb ? fb->format->cpp[0 ] *8 :32 ; + pitch = fb ? fb->pitches[0 ] : width * bpp /8 ; x_offset = vbox->single_framebuffer ? vbox_crtc->x : vbox_crtc->x_hint; y_offset = vbox->single_framebuffer ? vbox_crtc->y : vbox_crtc->y_hint;
@@ -66,14 +67,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc)* VirtualBox, certain parts of the code still assume that the first * screen is programmed this way, so try to fake it. */ -if (vbox_crtc->crtc_id ==0 && crtc->enabled && +if (vbox_crtc->crtc_id ==0 && fb && vbox_crtc->fb_offset / pitch <0xffff - crtc->y && vbox_crtc->fb_offset % (bpp /8 ) ==0 ) {vbox_write_ioport (VBE_DISPI_INDEX_XRES , width);vbox_write_ioport (VBE_DISPI_INDEX_YRES , height);vbox_write_ioport (VBE_DISPI_INDEX_VIRT_WIDTH , pitch *8 / bpp); -vbox_write_ioport (VBE_DISPI_INDEX_BPP , -CRTC_FB (crtc)->format->cpp[0 ] *8 ); +vbox_write_ioport (VBE_DISPI_INDEX_BPP , bpp);vbox_write_ioport (VBE_DISPI_INDEX_ENABLE ,VBE_DISPI_ENABLED ); vbox_write_ioport( VBE_DISPI_INDEX_X_OFFSET,
@@ -83,8 +83,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc) } flags =VBVA_SCREEN_F_ACTIVE ; - flags |= (crtc->enabled && !vbox_crtc->blanked) ? -0 :VBVA_SCREEN_F_BLANK ; + flags |= (fb && !vbox_crtc->blanked) ?0 :VBVA_SCREEN_F_BLANK ; flags |= vbox_crtc->disconnected ?VBVA_SCREEN_F_DISABLED :0 ; hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id, x_offset, y_offset,
@@ -176,7 +175,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)* Same fall-back if this is the fbdev frame-buffer. */ list_for_each_entry (crtci, &vbox->ddev.mode_config.crtc_list, head) { - fb =CRTC_FB (crtci); + fb = crtci->primary->state->fb;if (!fb)continue ;
Signature · 6 lines
2.19.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH RESEND 9/15 staging: vboxvideo: Atomic phase 3: Switch last bits over to atomic
In reply to Hans de GoedeNow that the state objects are wired up, we can:
1) Move to the final atomic handlers
2) Wire up atomic set_config helper
3) Switch to drm_mode_config_helper_suspend/resume for suspend/resume
4) Enable atomic modesetting ioctl
This is all done in one commit because doing this piecemeal leads to an intermediate state which triggers WARN_ONs in the atomic code because e.g. plane->fb is still being set.
--- drivers/staging/vboxvideo/TODO | 1 - drivers/staging/vboxvideo/vbox_drv.c | 40 +++++---------------------- drivers/staging/vboxvideo/vbox_mode.c | 35 +++++++---------------- 3 files changed, 17 insertions(+), 59 deletions(-)
drivers/staging/vboxvideo/TODO +0 -1
@@ -1,5 +1,4 @@ TODO: --Move the driver over to the atomic API -Get a full review from the drm-maintainers on dri-devel done on this driver -Extend this TODO with the results of that review
drivers/staging/vboxvideo/vbox_drv.c +7 -33
@@ -132,35 +132,16 @@ static void vbox_pci_remove(struct pci_dev *pdev)drm_dev_put (&vbox->ddev); } -static int vbox_drm_freeze (struct vbox_private *vbox) -{ -drm_kms_helper_poll_disable (&vbox->ddev); - -pci_save_state (vbox->ddev.pdev); - -drm_fb_helper_set_suspend_unlocked (&vbox->fbdev->helper, true); - -return 0 ; -} - -static int vbox_drm_thaw (struct vbox_private *vbox) -{ -drm_mode_config_reset (&vbox->ddev); -drm_helper_resume_force_mode (&vbox->ddev); -drm_fb_helper_set_suspend_unlocked (&vbox->fbdev->helper, false); - -return 0 ; -} -static int vbox_pm_suspend (struct device *dev) {struct vbox_private *vbox =dev_get_drvdata (dev);int error; - error =vbox_drm_freeze (vbox); + error =drm_mode_config_helper_suspend (&vbox->ddev);if (error)return error; +pci_save_state (vbox->ddev.pdev);pci_disable_device (vbox->ddev.pdev);pci_set_power_state (vbox->ddev.pdev, PCI_D3hot);
@@ -170,39 +151,32 @@ static int vbox_pm_suspend(struct device *dev)static int vbox_pm_resume (struct device *dev) {struct vbox_private *vbox =dev_get_drvdata (dev); -int ret;if (pci_enable_device (vbox->ddev.pdev))return -EIO ; - ret =vbox_drm_thaw (vbox); -if (ret) -return ret; - -drm_kms_helper_poll_enable (&vbox->ddev); - -return 0 ; +return drm_mode_config_helper_resume (&vbox->ddev); }static int vbox_pm_freeze (struct device *dev) {struct vbox_private *vbox =dev_get_drvdata (dev); -return vbox_drm_freeze (vbox); +return drm_mode_config_helper_suspend (&vbox->ddev); }static int vbox_pm_thaw (struct device *dev) {struct vbox_private *vbox =dev_get_drvdata (dev); -return vbox_drm_thaw (vbox); +return drm_mode_config_helper_resume (&vbox->ddev); }static int vbox_pm_poweroff (struct device *dev) {struct vbox_private *vbox =dev_get_drvdata (dev); -return vbox_drm_freeze (vbox); +return drm_mode_config_helper_suspend (&vbox->ddev); }static const struct dev_pm_ops vbox_pm_ops = {
@@ -280,7 +254,7 @@ static void vbox_master_drop(struct drm_device *dev, struct drm_file *file_priv)static struct drm_driver driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED | -DRIVER_PRIME , +DRIVER_PRIME |DRIVER_ATOMIC , .dev_priv_size =0 , .lastclose = vbox_driver_lastclose,
drivers/staging/vboxvideo/vbox_mode.c +10 -25
@@ -148,13 +148,6 @@ static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)mutex_unlock (&vbox->hw_mutex); } -static bool vbox_crtc_mode_fixup (struct drm_crtc *crtc, -const struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode) -{ -return true; -} -/* * Try to map the layout of virtual screens to the range of the input device. * Return true if we need to re-set the crtc modes due to screen offset
@@ -260,19 +253,10 @@ static void vbox_crtc_disable(struct drm_crtc *crtc) { } -static void vbox_crtc_prepare (struct drm_crtc *crtc) -{ -} -static void vbox_crtc_commit (struct drm_crtc *crtc) { } -static void vbox_crtc_mode_set_nofb (struct drm_crtc *crtc) -{ -/* We always set the mode when we set the fb/base */ -} -static void vbox_crtc_atomic_flush (struct drm_crtc *crtc,struct drm_crtc_state *old_crtc_state) {
@@ -291,11 +275,7 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = { .dpms = vbox_crtc_dpms, - .mode_fixup = vbox_crtc_mode_fixup, - .mode_set = drm_helper_crtc_mode_set, - .mode_set_nofb = vbox_crtc_mode_set_nofb, .disable = vbox_crtc_disable, - .prepare = vbox_crtc_prepare, .commit = vbox_crtc_commit, .atomic_flush = vbox_crtc_atomic_flush, };
@@ -307,7 +287,7 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc) }static const struct drm_crtc_funcs vbox_crtc_funcs = { - .set_config = drm_crtc_helper_set_config, + .set_config = drm_atomic_helper_set_config,/* .gamma_set = vbox_crtc_gamma_set, */ .destroy = vbox_crtc_destroy, .reset = drm_atomic_helper_crtc_reset,
@@ -521,8 +501,8 @@ static const struct drm_plane_helper_funcs vbox_cursor_helper_funcs = { };static const struct drm_plane_funcs vbox_cursor_plane_funcs = { - .update_plane = drm_plane_helper_update, - .disable_plane = drm_plane_helper_disable, + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, .destroy = drm_primary_helper_destroy, .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
@@ -543,8 +523,8 @@ static const struct drm_plane_helper_funcs vbox_primary_helper_funcs = { };static const struct drm_plane_funcs vbox_primary_plane_funcs = { - .update_plane = drm_plane_helper_update, - .disable_plane = drm_primary_helper_disable, + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, .destroy = drm_primary_helper_destroy, .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
@@ -882,6 +862,9 @@ static const struct drm_connector_funcs vbox_connector_funcs = { .detect = vbox_connector_detect, .fill_modes = vbox_fill_modes, .destroy = vbox_connector_destroy, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; static int vbox_connector_init(struct drm_device *dev,
@@ -950,6 +933,8 @@ static struct drm_framebuffer *vbox_user_framebuffer_create(static const struct drm_mode_config_funcs vbox_mode_funcs = { .fb_create = vbox_user_framebuffer_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, };int vbox_mode_init (struct vbox_private *vbox)
Signature · 6 lines
2.19.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH RESEND 10/15 staging: vboxvideo: Restore page-flip support
In reply to Hans de GoedeRestore page-flip support now that the atomic conversion is complete.
Since the mode parameter to vbox_crtc_set_base_and_mode() now never is NULL call drm_atomic_crtc_needs_modeset() to check if we need to check for input-mapping changes, to avoid doing unnecesarry work on a flip. And hookup the drm_atomic_helper_page_flip helper to implement the page_flip callback.
--- drivers/staging/vboxvideo/vbox_mode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/staging/vboxvideo/vbox_mode.c +5 -2
@@ -32,6 +32,7 @@* Hans de Goede <[email protected]> */ #include <linux/export.h> +#include <drm/drm_atomic.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> #include <drm/drm_atomic_helper.h>
@@ -217,6 +218,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,struct vbox_bo *bo =gem_to_vbox_bo (to_vbox_framebuffer (fb)->obj);struct vbox_private *vbox = crtc->dev->dev_private;struct vbox_crtc *vbox_crtc =to_vbox_crtc (crtc); +bool needs_modeset =drm_atomic_crtc_needs_modeset (crtc->state);mutex_lock (&vbox->hw_mutex);
@@ -227,7 +229,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, vbox_crtc->fb_offset =vbox_bo_gpu_offset (bo);/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */ -if (mode &&vbox_set_up_input_mapping (vbox)) { +if (needs_modeset &&vbox_set_up_input_mapping (vbox)) {struct drm_crtc *crtci; list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
@@ -241,7 +243,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,vbox_set_view (crtc);vbox_do_modeset (crtc); -if (mode) +if (needs_modeset)hgsmi_update_input_mapping (vbox->guest_pool,0 ,0 , vbox->input_mapping_width, vbox->input_mapping_height);
@@ -288,6 +290,7 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)static const struct drm_crtc_funcs vbox_crtc_funcs = { .set_config = drm_atomic_helper_set_config, + .page_flip = drm_atomic_helper_page_flip,/* .gamma_set = vbox_crtc_gamma_set, */ .destroy = vbox_crtc_destroy, .reset = drm_atomic_helper_crtc_reset,
Signature · 1 line
2.19.0
PATCH RESEND 11/15 staging: vboxvideo: Fix DPMS support after atomic conversion
In reply to Hans de GoedeAtomic modesetting does not use the traditional dpms call backs, instead we should check crtc_state->active.
--- drivers/staging/vboxvideo/vbox_drv.h | 1 - drivers/staging/vboxvideo/vbox_mode.c | 28 ++------------------------- 2 files changed, 2 insertions(+), 27 deletions(-)
drivers/staging/vboxvideo/vbox_drv.h +0 -1
@@ -139,7 +139,6 @@ struct vbox_connector {struct vbox_crtc {struct drm_crtc base; -bool blanked;bool disconnected;unsigned int crtc_id;u32 fb_offset;
drivers/staging/vboxvideo/vbox_mode.c +2 -26
@@ -84,14 +84,13 @@ static void vbox_do_modeset(struct drm_crtc *crtc) } flags =VBVA_SCREEN_F_ACTIVE ; - flags |= (fb && !vbox_crtc->blanked) ?0 :VBVA_SCREEN_F_BLANK ; + flags |= (fb && crtc->state->active) ?0 :VBVA_SCREEN_F_BLANK ; flags |= vbox_crtc->disconnected ?VBVA_SCREEN_F_DISABLED :0 ;hgsmi_process_display_info (vbox->guest_pool, vbox_crtc->crtc_id, x_offset, y_offset, vbox_crtc->x * bpp /8 + vbox_crtc->y * pitch, - pitch, width, height, - vbox_crtc->blanked ?0 : bpp, flags); + pitch, width, height, bpp, flags); }static int vbox_set_view (struct drm_crtc *crtc)
@@ -128,27 +127,6 @@ static int vbox_set_view(struct drm_crtc *crtc)return 0 ; } -static void vbox_crtc_dpms (struct drm_crtc *crtc,int mode) -{ -struct vbox_crtc *vbox_crtc =to_vbox_crtc (crtc); -struct vbox_private *vbox = crtc->dev->dev_private; - -switch (mode) { -case DRM_MODE_DPMS_ON : - vbox_crtc->blanked = false; -break ; -case DRM_MODE_DPMS_STANDBY : -case DRM_MODE_DPMS_SUSPEND : -case DRM_MODE_DPMS_OFF : - vbox_crtc->blanked = true; -break ; - } - -mutex_lock (&vbox->hw_mutex); -vbox_do_modeset (crtc); -mutex_unlock (&vbox->hw_mutex); -} -/* * Try to map the layout of virtual screens to the range of the input device. * Return true if we need to re-set the crtc modes due to screen offset
@@ -276,7 +254,6 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc, }static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = { - .dpms = vbox_crtc_dpms, .disable = vbox_crtc_disable, .commit = vbox_crtc_commit, .atomic_flush = vbox_crtc_atomic_flush,
@@ -861,7 +838,6 @@ static const struct drm_connector_helper_funcs vbox_connector_helper_funcs = { };static const struct drm_connector_funcs vbox_connector_funcs = { - .dpms = drm_helper_connector_dpms, .detect = vbox_connector_detect, .fill_modes = vbox_fill_modes, .destroy = vbox_connector_destroy,
Signature · 1 line
2.19.0
PATCH RESEND 12/15 staging: vboxvideo: Replace crtc_helper enable/disable functions
In reply to Hans de GoedeReplace vbox_crtc_commit and vbox_crtc_disable with vbox_crtc_atomic_[en|dis]able which are the preferred callbacks for these for atomic drivers.
--- drivers/staging/vboxvideo/vbox_mode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/vboxvideo/vbox_mode.c +6 -4
@@ -229,11 +229,13 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,mutex_unlock (&vbox->hw_mutex); } -static void vbox_crtc_disable (struct drm_crtc *crtc) +static void vbox_crtc_atomic_enable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) { } -static void vbox_crtc_commit (struct drm_crtc *crtc) +static void vbox_crtc_atomic_disable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) { }
@@ -254,8 +256,8 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc, }static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = { - .disable = vbox_crtc_disable, - .commit = vbox_crtc_commit, + .atomic_enable = vbox_crtc_atomic_enable, + .atomic_disable = vbox_crtc_atomic_disable, .atomic_flush = vbox_crtc_atomic_flush, };
Signature · 1 line
2.19.0
PATCH RESEND 13/15 staging: vboxvideo: Call drm_atomic_helper_check_plane_state from atomic_check
In reply to Hans de GoedeExtend our planes atomic_check callbacks to be more thorough by calling the drm_atomic_helper_check_plane_state helper.
--- drivers/staging/vboxvideo/vbox_mode.c | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
drivers/staging/vboxvideo/vbox_mode.c +29 -1
@@ -280,7 +280,19 @@ static const struct drm_crtc_funcs vbox_crtc_funcs = {static int vbox_primary_atomic_check (struct drm_plane *plane,struct drm_plane_state *new_state) { -return 0 ; +struct drm_crtc_state *crtc_state =NULL ; + +if (new_state->crtc) { + crtc_state =drm_atomic_get_existing_crtc_state ( + new_state->state, new_state->crtc); +if (WARN_ON (!crtc_state)) +return -EINVAL ; + } + +return drm_atomic_helper_check_plane_state (new_state, crtc_state, +DRM_PLANE_HELPER_NO_SCALING , +DRM_PLANE_HELPER_NO_SCALING , + false, true); } static void vbox_primary_atomic_update(struct drm_plane *plane,
@@ -337,8 +349,24 @@ static void vbox_primary_cleanup_fb(struct drm_plane *plane,static int vbox_cursor_atomic_check (struct drm_plane *plane,struct drm_plane_state *new_state) { +struct drm_crtc_state *crtc_state =NULL ;u32 width = new_state->crtc_w;u32 height = new_state->crtc_h; +int ret; + +if (new_state->crtc) { + crtc_state =drm_atomic_get_existing_crtc_state ( + new_state->state, new_state->crtc); +if (WARN_ON (!crtc_state)) +return -EINVAL ; + } + + ret =drm_atomic_helper_check_plane_state (new_state, crtc_state, +DRM_PLANE_HELPER_NO_SCALING , +DRM_PLANE_HELPER_NO_SCALING , + true, true); +if (ret) +return ret;if (!new_state->fb)return 0 ;
Signature · 1 line
2.19.0
PATCH RESEND 14/15 staging: vboxvideo: Drop unnecessary drm_connector_helper_funcs callbacks
In reply to Hans de Goedevbox_mode_valid always returns MODE_OK, which is also the default if no mode_valid callback is defined.
vbox_best_single_encoder chains to drm_encoder_find, the drm-core will call drm_encoder_find itself if there is no best_encoder call back.
--- drivers/staging/vboxvideo/vbox_mode.c | 20 -------------------- 1 file changed, 20 deletions(-)
drivers/staging/vboxvideo/vbox_mode.c +0 -20
@@ -651,18 +651,6 @@ static void vbox_encoder_destroy(struct drm_encoder *encoder)kfree (encoder); } -static struct drm_encoder *vbox_best_single_encoder (struct drm_connector - *connector) -{ -int enc_id = connector->encoder_ids[0 ]; - -/* pick the encoder ids */ -if (enc_id) -return drm_encoder_find (connector->dev,NULL , enc_id); - -return NULL ; -} -static const struct drm_encoder_funcs vbox_enc_funcs = { .destroy = vbox_encoder_destroy, };
@@ -820,12 +808,6 @@ static int vbox_get_modes(struct drm_connector *connector)return num_modes; } -static enum drm_mode_status vbox_mode_valid (struct drm_connector *connector, -struct drm_display_mode *mode) -{ -return MODE_OK ; -} -static void vbox_connector_destroy (struct drm_connector *connector) {drm_connector_unregister (connector);
@@ -862,9 +844,7 @@ static int vbox_fill_modes(struct drm_connector *connector, u32 max_x, }static const struct drm_connector_helper_funcs vbox_connector_helper_funcs = { - .mode_valid = vbox_mode_valid, .get_modes = vbox_get_modes, - .best_encoder = vbox_best_single_encoder, };static const struct drm_connector_funcs vbox_connector_funcs = {
Signature · 1 line
2.19.0
PATCH RESEND 15/15 staging: vboxvideo: Use more drm_fb_helper functions
In reply to Hans de GoedeStore fbhelper and afb struct directly in vbox_private and use drm_fb_helper_fbdev_setup to replace vbox_fbdev_init, note we cannot use drm_fb_helper_fbdev_teardown since we use a private framebuffer for the fbdev.
And replace vbox_driver_lastclose with drm_fb_helper_lastclose.
--- drivers/staging/vboxvideo/vbox_drv.c | 10 +++- drivers/staging/vboxvideo/vbox_drv.h | 28 +++-------- drivers/staging/vboxvideo/vbox_fb.c | 70 ++++++--------------------- drivers/staging/vboxvideo/vbox_main.c | 12 ----- drivers/staging/vboxvideo/vbox_mode.c | 2 +- 5 files changed, 31 insertions(+), 91 deletions(-)
drivers/staging/vboxvideo/vbox_drv.c +8 -2
@@ -49,6 +49,10 @@ static const struct pci_device_id pciidlist[] = { };MODULE_DEVICE_TABLE (pci, pciidlist); +static struct drm_fb_helper_funcs vbox_fb_helper_funcs = { + .fb_probe = vboxfb_create, +}; +static int vbox_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {struct vbox_private *vbox;
@@ -92,7 +96,9 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret) goto err_mode_fini; - ret =vbox_fbdev_init (vbox); + ret =drm_fb_helper_fbdev_setup (&vbox->ddev, &vbox->fb_helper, + &vbox_fb_helper_funcs,32 , + vbox->num_crtcs);if (ret) goto err_irq_fini;
@@ -257,7 +263,7 @@ static struct drm_driver driver = { DRIVER_PRIME | DRIVER_ATOMIC, .dev_priv_size = 0, - .lastclose = vbox_driver_lastclose, + .lastclose = drm_fb_helper_lastclose, .master_set = vbox_master_set, .master_drop = vbox_master_drop,
drivers/staging/vboxvideo/vbox_drv.h +8 -20
@@ -72,11 +72,16 @@ sizeof(struct hgsmi_host_flags))#define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE -struct vbox_fbdev ; +struct vbox_framebuffer { +struct drm_framebuffer base; +struct drm_gem_object *obj; +};struct vbox_private {/* Must be first; or we must define our own release callback */ struct drm_device ddev; +struct drm_fb_helper fb_helper; +struct vbox_framebuffer afb;u8 __iomem *guest_heap;u8 __iomem *vbva_buffers;
@@ -91,8 +96,6 @@ struct vbox_private {/** Array of structures for receiving mode hints. */ struct vbva_modehint *last_mode_hints; -struct vbox_fbdev *fbdev; -int fb_mtrr;struct {
@@ -122,8 +125,6 @@ struct vbox_private {#undef CURSOR_PIXEL_COUNT#undef CURSOR_DATA_SIZE -void vbox_driver_lastclose (struct drm_device *dev); -struct vbox_gem_object ;struct vbox_connector {
@@ -171,20 +172,6 @@ struct vbox_encoder {struct drm_encoder base; }; -struct vbox_framebuffer { -struct drm_framebuffer base; -struct drm_gem_object *obj; -}; - -struct vbox_fbdev { -struct drm_fb_helper helper; -struct vbox_framebuffer afb; -int size; -struct ttm_bo_kmap_obj mapping; -int x1, y1, x2, y2;/* dirty rect */ -spinlock_t dirty_lock; -}; -#define to_vbox_crtc (x) container_of(x, struct vbox_crtc, base)#define to_vbox_connector (x) container_of(x, struct vbox_connector, base)#define to_vbox_encoder (x) container_of(x, struct vbox_encoder, base)
@@ -212,7 +199,8 @@ int vbox_framebuffer_init(struct vbox_private *vbox,const struct DRM_MODE_FB_CMD *mode_cmd, struct drm_gem_object *obj); -int vbox_fbdev_init (struct vbox_private *vbox); +int vboxfb_create (struct drm_fb_helper *helper, +struct drm_fb_helper_surface_size *sizes);void vbox_fbdev_fini (struct vbox_private *vbox);struct vbox_bo {
drivers/staging/vboxvideo/vbox_fb.c +14 -56
115 lines not on this page · raw message
drivers/staging/vboxvideo/vbox_main.c +0 -12
@@ -322,18 +322,6 @@ void vbox_hw_fini(struct vbox_private *vbox)pci_iounmap (vbox->ddev.pdev, vbox->guest_heap); } -/** -* @note this is described in the DRM framework documentation. AST does not -* have it, but we get an oops on driver unload if it is not present. -*/ -void vbox_driver_lastclose (struct drm_device *dev) -{ -struct vbox_private *vbox = dev->dev_private; - -if (vbox->fbdev) -drm_fb_helper_restore_fbdev_mode_unlocked (&vbox->fbdev->helper); -} -int vbox_gem_create (struct vbox_private *vbox,u32 size,bool iskernel,struct drm_gem_object **obj) {
drivers/staging/vboxvideo/vbox_mode.c +1 -1
@@ -153,7 +153,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)if (!fb1) { fb1 = fb; -if (to_vbox_framebuffer (fb1) == &vbox->fbdev->afb) +if (to_vbox_framebuffer (fb1) == &vbox->afb)break ; }else if (fb != fb1) { single_framebuffer = false;
Signature · 1 line
2.19.0
Why are you resending this? It's because you added some more patches on the end? Just send those as a new series...
regards,
dan carpenter
Hi,
Quoted 2 lines · Dan Carpenter
Why are you resending this? It's because you added some more patches on the end? Just send those as a new series...
I accidentally numbered the cover-letter of the original series 01/15 instea dof 00/15 this confused Greg, so he asked for a resend.
Nothing is changed in the resend, otherwise I would have made the series a v2 and not a resend.
Regards,
Hans
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 11 lines · Hans de Goede
Hi,
Quoted 2 lines · Dan Carpenter
Why are you resending this? It's because you added some more patches on the end? Just send those as a new series...
I accidentally numbered the cover-letter of the original series 01/15 instea dof 00/15 this confused Greg, so he asked for a resend.
Nothing is changed in the resend, otherwise I would have made the series a v2 and not a resend.
I'm assuming this all lands for 4.20/5.0, since I've just merged the series to nuke the transitional helpers for good for 2.21/5.1. Worst case we just need to pull this in as a topic branch, based on a sufficiently old-enough kernel.
Cheers, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi,
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Hans de Goede
Hi,
Quoted 2 lines · Dan Carpenter
Why are you resending this? It's because you added some more patches on the end? Just send those as a new series...
Quoted 7 lines
Quoted 5 lines
I accidentally numbered the cover-letter of the original series 01/15 instea dof 00/15 this confused Greg, so he asked for a resend.
Nothing is changed in the resend, otherwise I would have made the series a v2 and not a resend.
I'm assuming this all lands for 4.20/5.0,
Yes Greg has the entire series queued up in staging-next.
Regards,
Hans
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel