Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
bbbed888
Commit
bbbed888
authored
May 26, 2016
by
Gerd Hoffmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
virtio-gpu: switch to atomic cursor interfaces
Signed-off-by:
Gerd Hoffmann
<
kraxel@redhat.com
>
parent
e7cf0963
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
99 deletions
+109
-99
drivers/gpu/drm/virtio/virtgpu_display.c
drivers/gpu/drm/virtio/virtgpu_display.c
+12
-90
drivers/gpu/drm/virtio/virtgpu_drv.h
drivers/gpu/drm/virtio/virtgpu_drv.h
+1
-0
drivers/gpu/drm/virtio/virtgpu_plane.c
drivers/gpu/drm/virtio/virtgpu_plane.c
+96
-9
No files found.
drivers/gpu/drm/virtio/virtgpu_display.c
View file @
bbbed888
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
#include <drm/drm_crtc_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic_helper.h>
#define XRES_MIN
320
#define XRES_MIN
32
#define YRES_MIN
200
#define YRES_MIN
32
#define XRES_DEF 1024
#define XRES_DEF 1024
#define YRES_DEF 768
#define YRES_DEF 768
...
@@ -38,86 +38,6 @@
...
@@ -38,86 +38,6 @@
#define XRES_MAX 8192
#define XRES_MAX 8192
#define YRES_MAX 8192
#define YRES_MAX 8192
static
void
virtio_gpu_hide_cursor
(
struct
virtio_gpu_device
*
vgdev
,
struct
virtio_gpu_output
*
output
)
{
output
->
cursor
.
hdr
.
type
=
cpu_to_le32
(
VIRTIO_GPU_CMD_UPDATE_CURSOR
);
output
->
cursor
.
resource_id
=
0
;
virtio_gpu_cursor_ping
(
vgdev
,
output
);
}
static
int
virtio_gpu_crtc_cursor_set
(
struct
drm_crtc
*
crtc
,
struct
drm_file
*
file_priv
,
uint32_t
handle
,
uint32_t
width
,
uint32_t
height
,
int32_t
hot_x
,
int32_t
hot_y
)
{
struct
virtio_gpu_device
*
vgdev
=
crtc
->
dev
->
dev_private
;
struct
virtio_gpu_output
*
output
=
container_of
(
crtc
,
struct
virtio_gpu_output
,
crtc
);
struct
drm_gem_object
*
gobj
=
NULL
;
struct
virtio_gpu_object
*
qobj
=
NULL
;
struct
virtio_gpu_fence
*
fence
=
NULL
;
int
ret
=
0
;
if
(
handle
==
0
)
{
virtio_gpu_hide_cursor
(
vgdev
,
output
);
return
0
;
}
/* lookup the cursor */
gobj
=
drm_gem_object_lookup
(
file_priv
,
handle
);
if
(
gobj
==
NULL
)
return
-
ENOENT
;
qobj
=
gem_to_virtio_gpu_obj
(
gobj
);
if
(
!
qobj
->
hw_res_handle
)
{
ret
=
-
EINVAL
;
goto
out
;
}
virtio_gpu_cmd_transfer_to_host_2d
(
vgdev
,
qobj
->
hw_res_handle
,
0
,
cpu_to_le32
(
64
),
cpu_to_le32
(
64
),
0
,
0
,
&
fence
);
ret
=
virtio_gpu_object_reserve
(
qobj
,
false
);
if
(
!
ret
)
{
reservation_object_add_excl_fence
(
qobj
->
tbo
.
resv
,
&
fence
->
f
);
fence_put
(
&
fence
->
f
);
virtio_gpu_object_unreserve
(
qobj
);
virtio_gpu_object_wait
(
qobj
,
false
);
}
output
->
cursor
.
hdr
.
type
=
cpu_to_le32
(
VIRTIO_GPU_CMD_UPDATE_CURSOR
);
output
->
cursor
.
resource_id
=
cpu_to_le32
(
qobj
->
hw_res_handle
);
output
->
cursor
.
hot_x
=
cpu_to_le32
(
hot_x
);
output
->
cursor
.
hot_y
=
cpu_to_le32
(
hot_y
);
virtio_gpu_cursor_ping
(
vgdev
,
output
);
ret
=
0
;
out:
drm_gem_object_unreference_unlocked
(
gobj
);
return
ret
;
}
static
int
virtio_gpu_crtc_cursor_move
(
struct
drm_crtc
*
crtc
,
int
x
,
int
y
)
{
struct
virtio_gpu_device
*
vgdev
=
crtc
->
dev
->
dev_private
;
struct
virtio_gpu_output
*
output
=
container_of
(
crtc
,
struct
virtio_gpu_output
,
crtc
);
output
->
cursor
.
hdr
.
type
=
cpu_to_le32
(
VIRTIO_GPU_CMD_MOVE_CURSOR
);
output
->
cursor
.
pos
.
x
=
cpu_to_le32
(
x
);
output
->
cursor
.
pos
.
y
=
cpu_to_le32
(
y
);
virtio_gpu_cursor_ping
(
vgdev
,
output
);
return
0
;
}
static
int
virtio_gpu_page_flip
(
struct
drm_crtc
*
crtc
,
static
int
virtio_gpu_page_flip
(
struct
drm_crtc
*
crtc
,
struct
drm_framebuffer
*
fb
,
struct
drm_framebuffer
*
fb
,
struct
drm_pending_vblank_event
*
event
,
struct
drm_pending_vblank_event
*
event
,
...
@@ -164,8 +84,6 @@ static int virtio_gpu_page_flip(struct drm_crtc *crtc,
...
@@ -164,8 +84,6 @@ static int virtio_gpu_page_flip(struct drm_crtc *crtc,
}
}
static
const
struct
drm_crtc_funcs
virtio_gpu_crtc_funcs
=
{
static
const
struct
drm_crtc_funcs
virtio_gpu_crtc_funcs
=
{
.
cursor_set2
=
virtio_gpu_crtc_cursor_set
,
.
cursor_move
=
virtio_gpu_crtc_cursor_move
,
.
set_config
=
drm_atomic_helper_set_config
,
.
set_config
=
drm_atomic_helper_set_config
,
.
destroy
=
drm_crtc_cleanup
,
.
destroy
=
drm_crtc_cleanup
,
...
@@ -406,7 +324,7 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
...
@@ -406,7 +324,7 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
struct
drm_connector
*
connector
=
&
output
->
conn
;
struct
drm_connector
*
connector
=
&
output
->
conn
;
struct
drm_encoder
*
encoder
=
&
output
->
enc
;
struct
drm_encoder
*
encoder
=
&
output
->
enc
;
struct
drm_crtc
*
crtc
=
&
output
->
crtc
;
struct
drm_crtc
*
crtc
=
&
output
->
crtc
;
struct
drm_plane
*
p
lane
;
struct
drm_plane
*
p
rimary
,
*
cursor
;
output
->
index
=
index
;
output
->
index
=
index
;
if
(
index
==
0
)
{
if
(
index
==
0
)
{
...
@@ -415,13 +333,17 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
...
@@ -415,13 +333,17 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
output
->
info
.
r
.
height
=
cpu_to_le32
(
YRES_DEF
);
output
->
info
.
r
.
height
=
cpu_to_le32
(
YRES_DEF
);
}
}
plane
=
virtio_gpu_plane_init
(
vgdev
,
index
);
primary
=
virtio_gpu_plane_init
(
vgdev
,
DRM_PLANE_TYPE_PRIMARY
,
index
);
if
(
IS_ERR
(
plane
))
if
(
IS_ERR
(
primary
))
return
PTR_ERR
(
plane
);
return
PTR_ERR
(
primary
);
drm_crtc_init_with_planes
(
dev
,
crtc
,
plane
,
NULL
,
cursor
=
virtio_gpu_plane_init
(
vgdev
,
DRM_PLANE_TYPE_CURSOR
,
index
);
if
(
IS_ERR
(
cursor
))
return
PTR_ERR
(
cursor
);
drm_crtc_init_with_planes
(
dev
,
crtc
,
primary
,
cursor
,
&
virtio_gpu_crtc_funcs
,
NULL
);
&
virtio_gpu_crtc_funcs
,
NULL
);
drm_crtc_helper_add
(
crtc
,
&
virtio_gpu_crtc_helper_funcs
);
drm_crtc_helper_add
(
crtc
,
&
virtio_gpu_crtc_helper_funcs
);
plane
->
crtc
=
crtc
;
primary
->
crtc
=
crtc
;
cursor
->
crtc
=
crtc
;
drm_connector_init
(
dev
,
connector
,
&
virtio_gpu_connector_funcs
,
drm_connector_init
(
dev
,
connector
,
&
virtio_gpu_connector_funcs
,
DRM_MODE_CONNECTOR_VIRTUAL
);
DRM_MODE_CONNECTOR_VIRTUAL
);
...
...
drivers/gpu/drm/virtio/virtgpu_drv.h
View file @
bbbed888
...
@@ -336,6 +336,7 @@ void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
...
@@ -336,6 +336,7 @@ void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
/* virtio_gpu_plane.c */
/* virtio_gpu_plane.c */
struct
drm_plane
*
virtio_gpu_plane_init
(
struct
virtio_gpu_device
*
vgdev
,
struct
drm_plane
*
virtio_gpu_plane_init
(
struct
virtio_gpu_device
*
vgdev
,
enum
drm_plane_type
type
,
int
index
);
int
index
);
/* virtio_gpu_ttm.c */
/* virtio_gpu_ttm.c */
...
...
drivers/gpu/drm/virtio/virtgpu_plane.c
View file @
bbbed888
...
@@ -38,6 +38,10 @@ static const uint32_t virtio_gpu_formats[] = {
...
@@ -38,6 +38,10 @@ static const uint32_t virtio_gpu_formats[] = {
DRM_FORMAT_ABGR8888
,
DRM_FORMAT_ABGR8888
,
};
};
static
const
uint32_t
virtio_gpu_cursor_formats
[]
=
{
DRM_FORMAT_ARGB8888
,
};
static
void
virtio_gpu_plane_destroy
(
struct
drm_plane
*
plane
)
static
void
virtio_gpu_plane_destroy
(
struct
drm_plane
*
plane
)
{
{
kfree
(
plane
);
kfree
(
plane
);
...
@@ -58,8 +62,8 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
...
@@ -58,8 +62,8 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
return
0
;
return
0
;
}
}
static
void
virtio_gpu_p
lane_atomic
_update
(
struct
drm_plane
*
plane
,
static
void
virtio_gpu_p
rimary_plane
_update
(
struct
drm_plane
*
plane
,
struct
drm_plane_state
*
old_state
)
struct
drm_plane_state
*
old_state
)
{
{
struct
drm_device
*
dev
=
plane
->
dev
;
struct
drm_device
*
dev
=
plane
->
dev
;
struct
virtio_gpu_device
*
vgdev
=
dev
->
dev_private
;
struct
virtio_gpu_device
*
vgdev
=
dev
->
dev_private
;
...
@@ -104,32 +108,115 @@ static void virtio_gpu_plane_atomic_update(struct drm_plane *plane,
...
@@ -104,32 +108,115 @@ static void virtio_gpu_plane_atomic_update(struct drm_plane *plane,
plane
->
state
->
crtc_h
);
plane
->
state
->
crtc_h
);
}
}
static
void
virtio_gpu_cursor_plane_update
(
struct
drm_plane
*
plane
,
struct
drm_plane_state
*
old_state
)
{
struct
drm_device
*
dev
=
plane
->
dev
;
struct
virtio_gpu_device
*
vgdev
=
dev
->
dev_private
;
struct
virtio_gpu_output
*
output
=
NULL
;
struct
virtio_gpu_framebuffer
*
vgfb
;
struct
virtio_gpu_fence
*
fence
=
NULL
;
struct
virtio_gpu_object
*
bo
=
NULL
;
uint32_t
handle
;
int
ret
=
0
;
static
const
struct
drm_plane_helper_funcs
virtio_gpu_plane_helper_funcs
=
{
if
(
plane
->
state
->
crtc
)
output
=
drm_crtc_to_virtio_gpu_output
(
plane
->
state
->
crtc
);
if
(
old_state
->
crtc
)
output
=
drm_crtc_to_virtio_gpu_output
(
old_state
->
crtc
);
WARN_ON
(
!
output
);
if
(
plane
->
state
->
fb
)
{
vgfb
=
to_virtio_gpu_framebuffer
(
plane
->
state
->
fb
);
bo
=
gem_to_virtio_gpu_obj
(
vgfb
->
obj
);
handle
=
bo
->
hw_res_handle
;
}
else
{
handle
=
0
;
}
if
(
bo
&&
bo
->
dumb
&&
(
plane
->
state
->
fb
!=
old_state
->
fb
))
{
/* new cursor -- update & wait */
virtio_gpu_cmd_transfer_to_host_2d
(
vgdev
,
handle
,
0
,
cpu_to_le32
(
plane
->
state
->
crtc_w
),
cpu_to_le32
(
plane
->
state
->
crtc_h
),
0
,
0
,
&
fence
);
ret
=
virtio_gpu_object_reserve
(
bo
,
false
);
if
(
!
ret
)
{
reservation_object_add_excl_fence
(
bo
->
tbo
.
resv
,
&
fence
->
f
);
fence_put
(
&
fence
->
f
);
fence
=
NULL
;
virtio_gpu_object_unreserve
(
bo
);
virtio_gpu_object_wait
(
bo
,
false
);
}
}
if
(
plane
->
state
->
fb
!=
old_state
->
fb
)
{
DRM_DEBUG
(
"update, handle %d, +%d+%d
\n
"
,
handle
,
plane
->
state
->
crtc_x
,
plane
->
state
->
crtc_y
);
output
->
cursor
.
hdr
.
type
=
cpu_to_le32
(
VIRTIO_GPU_CMD_UPDATE_CURSOR
);
output
->
cursor
.
resource_id
=
cpu_to_le32
(
handle
);
#if 0
/* TODO */
output->cursor.hot_x = cpu_to_le32(hot_x);
output->cursor.hot_y = cpu_to_le32(hot_y);
#endif
}
else
{
DRM_DEBUG
(
"move +%d+%d
\n
"
,
plane
->
state
->
crtc_x
,
plane
->
state
->
crtc_y
);
output
->
cursor
.
hdr
.
type
=
cpu_to_le32
(
VIRTIO_GPU_CMD_MOVE_CURSOR
);
}
output
->
cursor
.
pos
.
x
=
cpu_to_le32
(
plane
->
state
->
crtc_x
);
output
->
cursor
.
pos
.
y
=
cpu_to_le32
(
plane
->
state
->
crtc_y
);
virtio_gpu_cursor_ping
(
vgdev
,
output
);
}
static
const
struct
drm_plane_helper_funcs
virtio_gpu_primary_helper_funcs
=
{
.
atomic_check
=
virtio_gpu_plane_atomic_check
,
.
atomic_check
=
virtio_gpu_plane_atomic_check
,
.
atomic_update
=
virtio_gpu_plane_atomic_update
,
.
atomic_update
=
virtio_gpu_primary_plane_update
,
};
static
const
struct
drm_plane_helper_funcs
virtio_gpu_cursor_helper_funcs
=
{
.
atomic_check
=
virtio_gpu_plane_atomic_check
,
.
atomic_update
=
virtio_gpu_cursor_plane_update
,
};
};
struct
drm_plane
*
virtio_gpu_plane_init
(
struct
virtio_gpu_device
*
vgdev
,
struct
drm_plane
*
virtio_gpu_plane_init
(
struct
virtio_gpu_device
*
vgdev
,
enum
drm_plane_type
type
,
int
index
)
int
index
)
{
{
struct
drm_device
*
dev
=
vgdev
->
ddev
;
struct
drm_device
*
dev
=
vgdev
->
ddev
;
const
struct
drm_plane_helper_funcs
*
funcs
;
struct
drm_plane
*
plane
;
struct
drm_plane
*
plane
;
int
ret
;
const
uint32_t
*
formats
;
int
ret
,
nformats
;
plane
=
kzalloc
(
sizeof
(
*
plane
),
GFP_KERNEL
);
plane
=
kzalloc
(
sizeof
(
*
plane
),
GFP_KERNEL
);
if
(
!
plane
)
if
(
!
plane
)
return
ERR_PTR
(
-
ENOMEM
);
return
ERR_PTR
(
-
ENOMEM
);
if
(
type
==
DRM_PLANE_TYPE_CURSOR
)
{
formats
=
virtio_gpu_cursor_formats
;
nformats
=
ARRAY_SIZE
(
virtio_gpu_cursor_formats
);
funcs
=
&
virtio_gpu_cursor_helper_funcs
;
}
else
{
formats
=
virtio_gpu_formats
;
nformats
=
ARRAY_SIZE
(
virtio_gpu_formats
);
funcs
=
&
virtio_gpu_primary_helper_funcs
;
}
ret
=
drm_universal_plane_init
(
dev
,
plane
,
1
<<
index
,
ret
=
drm_universal_plane_init
(
dev
,
plane
,
1
<<
index
,
&
virtio_gpu_plane_funcs
,
&
virtio_gpu_plane_funcs
,
virtio_gpu_formats
,
formats
,
nformats
,
ARRAY_SIZE
(
virtio_gpu_formats
),
type
,
NULL
);
DRM_PLANE_TYPE_PRIMARY
,
NULL
);
if
(
ret
)
if
(
ret
)
goto
err_plane_init
;
goto
err_plane_init
;
drm_plane_helper_add
(
plane
,
&
virtio_gpu_plane_helper_
funcs
);
drm_plane_helper_add
(
plane
,
funcs
);
return
plane
;
return
plane
;
err_plane_init:
err_plane_init:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment