diff mbox

[V2,4/5] drm/vkms: Add connectors helpers

Message ID c8e2d9aec8edb49582e312214fab7f4f8a725ae9.1529582970.git.rodrigosiqueiramelo@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rodrigo Siqueira June 21, 2018, 12:17 p.m. UTC
This patch adds the struct drm_connector_helper_funcs with some
necessary hooks. Additionally, it also adds some missing hooks at
drm_connector_funcs.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
 drivers/gpu/drm/vkms/vkms_drv.c    |  6 ------
 drivers/gpu/drm/vkms/vkms_drv.h    |  9 +++++++++
 drivers/gpu/drm/vkms/vkms_output.c | 27 +++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 6 deletions(-)

Comments

Daniel Vetter July 11, 2018, 7:29 a.m. UTC | #1
On Thu, Jun 21, 2018 at 09:17:09AM -0300, Rodrigo Siqueira wrote:
> This patch adds the struct drm_connector_helper_funcs with some
> necessary hooks. Additionally, it also adds some missing hooks at
> drm_connector_funcs.
> 
> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> ---
>  drivers/gpu/drm/vkms/vkms_drv.c    |  6 ------
>  drivers/gpu/drm/vkms/vkms_drv.h    |  9 +++++++++
>  drivers/gpu/drm/vkms/vkms_output.c | 27 +++++++++++++++++++++++++++
>  3 files changed, 36 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index cc046fff985c..fe93f8c17997 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> @@ -19,12 +19,6 @@
>  #define DRIVER_MAJOR	1
>  #define DRIVER_MINOR	0
>  
> -#define XRES_MIN    32
> -#define YRES_MIN    32
> -
> -#define XRES_MAX  8192
> -#define YRES_MAX  8192
> -
>  static struct vkms_device *vkms_device;
>  
>  static const struct file_operations vkms_driver_fops = {
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index 54bb3dd2b2c1..76f1720f81a5 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -6,6 +6,15 @@
>  #include <drm/drm_gem.h>
>  #include <drm/drm_encoder.h>
>  
> +#define XRES_MIN    32
> +#define YRES_MIN    32
> +
> +#define XRES_DEF  1024
> +#define YRES_DEF   768
> +
> +#define XRES_MAX  8192
> +#define YRES_MAX  8192
> +
>  static const u32 vkms_formats[] = {
>  	DRM_FORMAT_XRGB8888,
>  };
> diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
> index 48143eac3c12..fef3b1c1b054 100644
> --- a/drivers/gpu/drm/vkms/vkms_output.c
> +++ b/drivers/gpu/drm/vkms/vkms_output.c
> @@ -8,6 +8,7 @@
>  
>  #include "vkms_drv.h"
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_atomic_helper.h>
>  
>  static void vkms_connector_destroy(struct drm_connector *connector)
>  {
> @@ -18,12 +19,36 @@ static void vkms_connector_destroy(struct drm_connector *connector)
>  static const struct drm_connector_funcs vkms_connector_funcs = {
>  	.fill_modes = drm_helper_probe_single_connector_modes,
>  	.destroy = vkms_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 const struct drm_encoder_funcs vkms_encoder_funcs = {
>  	.destroy = drm_encoder_cleanup,
>  };
>  
> +static int vkms_conn_get_modes(struct drm_connector *connector)
> +{
> +	int count;
> +
> +	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
> +	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
> +
> +	return count;
> +}
> +
> +static int vkms_conn_mode_valid(struct drm_connector *connector,
> +				struct drm_display_mode *mode)
> +{
> +	return MODE_OK;
> +}

No need to implement this dummy function, it's the default behaviour.
Please remove. Otherwise lgtm.

Thanks, Daniel

> +
> +static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = {
> +	.get_modes    = vkms_conn_get_modes,
> +	.mode_valid   = vkms_conn_mode_valid,
> +};
> +
>  int vkms_output_init(struct vkms_device *vkmsdev)
>  {
>  	struct vkms_output *output = &vkmsdev->output;
> @@ -49,6 +74,8 @@ int vkms_output_init(struct vkms_device *vkmsdev)
>  		goto err_connector;
>  	}
>  
> +	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
> +
>  	ret = drm_connector_register(connector);
>  	if (ret) {
>  		DRM_ERROR("Failed to register connector\n");
> -- 
> 2.17.1
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index cc046fff985c..fe93f8c17997 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -19,12 +19,6 @@ 
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
-#define XRES_MIN    32
-#define YRES_MIN    32
-
-#define XRES_MAX  8192
-#define YRES_MAX  8192
-
 static struct vkms_device *vkms_device;
 
 static const struct file_operations vkms_driver_fops = {
diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
index 54bb3dd2b2c1..76f1720f81a5 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.h
+++ b/drivers/gpu/drm/vkms/vkms_drv.h
@@ -6,6 +6,15 @@ 
 #include <drm/drm_gem.h>
 #include <drm/drm_encoder.h>
 
+#define XRES_MIN    32
+#define YRES_MIN    32
+
+#define XRES_DEF  1024
+#define YRES_DEF   768
+
+#define XRES_MAX  8192
+#define YRES_MAX  8192
+
 static const u32 vkms_formats[] = {
 	DRM_FORMAT_XRGB8888,
 };
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index 48143eac3c12..fef3b1c1b054 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -8,6 +8,7 @@ 
 
 #include "vkms_drv.h"
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_atomic_helper.h>
 
 static void vkms_connector_destroy(struct drm_connector *connector)
 {
@@ -18,12 +19,36 @@  static void vkms_connector_destroy(struct drm_connector *connector)
 static const struct drm_connector_funcs vkms_connector_funcs = {
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = vkms_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 const struct drm_encoder_funcs vkms_encoder_funcs = {
 	.destroy = drm_encoder_cleanup,
 };
 
+static int vkms_conn_get_modes(struct drm_connector *connector)
+{
+	int count;
+
+	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
+	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
+
+	return count;
+}
+
+static int vkms_conn_mode_valid(struct drm_connector *connector,
+				struct drm_display_mode *mode)
+{
+	return MODE_OK;
+}
+
+static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = {
+	.get_modes    = vkms_conn_get_modes,
+	.mode_valid   = vkms_conn_mode_valid,
+};
+
 int vkms_output_init(struct vkms_device *vkmsdev)
 {
 	struct vkms_output *output = &vkmsdev->output;
@@ -49,6 +74,8 @@  int vkms_output_init(struct vkms_device *vkmsdev)
 		goto err_connector;
 	}
 
+	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
+
 	ret = drm_connector_register(connector);
 	if (ret) {
 		DRM_ERROR("Failed to register connector\n");