Skip to content

Commit 2df7af9

Browse files
Sylfrenamelissawen
authored andcommitted
drm/vkms: Add vkms_config type
Currently, data for the device instance is held by vkms_device. Add a separate type, vkms_config to contain configuration details for the device and various modes to be later used by configfs. This config data stays constant once the device is created. Accordingly, add vkms_create and vkms_destroy to initialize/destroy device through configfs. Currently, they are being called from vkms_init and vkms_exit, but will be evoked from configfs later on. When configfs is added, device configuration will be tracked by configfs and only vkms device lifetime will be handled by vkms_init and vkms_exit functions. Modify usage of enable_cursor feature to reflect the changes in relevant files. Co-developed-by: Daniel Vetter <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Signed-off-by: Sumera Priyadarsini <[email protected]> Reviewed-by: Melissa Wen <[email protected]> Signed-off-by: Melissa Wen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/a090ad29b826185df30f80c66932dd2173d7b060.1610391685.git.sylphrenadin@gmail.com
1 parent cc3283f commit 2df7af9

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

drivers/gpu/drm/vkms/vkms_drv.c

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#define DRIVER_MAJOR 1
3535
#define DRIVER_MINOR 0
3636

37-
static struct vkms_device *vkms_device;
37+
static struct vkms_config *default_config;
3838

39-
bool enable_cursor = true;
39+
static bool enable_cursor = true;
4040
module_param_named(enable_cursor, enable_cursor, bool, 0444);
4141
MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support");
4242

@@ -122,10 +122,11 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev)
122122
return vkms_output_init(vkmsdev, 0);
123123
}
124124

125-
static int __init vkms_init(void)
125+
static int vkms_create(struct vkms_config *config)
126126
{
127127
int ret;
128128
struct platform_device *pdev;
129+
struct vkms_device *vkms_device;
129130

130131
pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
131132
if (IS_ERR(pdev))
@@ -143,6 +144,8 @@ static int __init vkms_init(void)
143144
goto out_devres;
144145
}
145146
vkms_device->platform = pdev;
147+
vkms_device->config = config;
148+
config->dev = vkms_device;
146149

147150
ret = dma_coerce_mask_and_coherent(vkms_device->drm.dev,
148151
DMA_BIT_MASK(64));
@@ -179,21 +182,42 @@ static int __init vkms_init(void)
179182
return ret;
180183
}
181184

182-
static void __exit vkms_exit(void)
185+
static int __init vkms_init(void)
186+
{
187+
struct vkms_config *config = kmalloc(sizeof(*config), GFP_KERNEL);
188+
189+
default_config = config;
190+
191+
config->cursor = enable_cursor;
192+
193+
return vkms_create(config);
194+
}
195+
196+
static void vkms_destroy(struct vkms_config *config)
183197
{
184198
struct platform_device *pdev;
185199

186-
if (!vkms_device) {
200+
if (!config->dev) {
187201
DRM_INFO("vkms_device is NULL.\n");
188202
return;
189203
}
190204

191-
pdev = vkms_device->platform;
205+
pdev = config->dev->platform;
192206

193-
drm_dev_unregister(&vkms_device->drm);
194-
drm_atomic_helper_shutdown(&vkms_device->drm);
207+
drm_dev_unregister(&config->dev->drm);
208+
drm_atomic_helper_shutdown(&config->dev->drm);
195209
devres_release_group(&pdev->dev, NULL);
196210
platform_device_unregister(pdev);
211+
212+
config->dev = NULL;
213+
}
214+
215+
static void __exit vkms_exit(void)
216+
{
217+
if (default_config->dev)
218+
vkms_destroy(default_config);
219+
220+
kfree(default_config);
197221
}
198222

199223
module_init(vkms_init);

drivers/gpu/drm/vkms/vkms_drv.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#define XRES_MAX 8192
2020
#define YRES_MAX 8192
2121

22-
extern bool enable_cursor;
23-
2422
struct vkms_composer {
2523
struct drm_framebuffer fb;
2624
struct drm_rect src, dst;
@@ -82,10 +80,19 @@ struct vkms_output {
8280
spinlock_t composer_lock;
8381
};
8482

83+
struct vkms_device;
84+
85+
struct vkms_config {
86+
bool cursor;
87+
/* only set when instantiated */
88+
struct vkms_device *dev;
89+
};
90+
8591
struct vkms_device {
8692
struct drm_device drm;
8793
struct platform_device *platform;
8894
struct vkms_output output;
95+
const struct vkms_config *config;
8996
};
9097

9198
#define drm_crtc_to_vkms_output(target) \

drivers/gpu/drm/vkms/vkms_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index)
4646
if (IS_ERR(primary))
4747
return PTR_ERR(primary);
4848

49-
if (enable_cursor) {
49+
if (vkmsdev->config->cursor) {
5050
cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index);
5151
if (IS_ERR(cursor)) {
5252
ret = PTR_ERR(cursor);
@@ -98,7 +98,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index)
9898
drm_crtc_cleanup(crtc);
9999

100100
err_crtc:
101-
if (enable_cursor)
101+
if (vkmsdev->config->cursor)
102102
drm_plane_cleanup(cursor);
103103

104104
err_cursor:

0 commit comments

Comments
 (0)