[PATCH v4 13/16] drm/dsi: Implement DCS {get,set}_pixel_format commands

2014-11-04 Thread Thierry Reding
On Mon, Nov 03, 2014 at 12:10:29PM -0500, Sean Paul wrote:
> On Mon, Nov 3, 2014 at 4:13 AM, Thierry Reding  
> wrote:
> > From: Thierry Reding 
> >
> > Provide small convenience wrappers to query or set the pixel format used
> > by the interface.
> >
> > Signed-off-by: Thierry Reding 
> > ---
> >  drivers/gpu/drm/drm_mipi_dsi.c | 42 
> > ++
> >  include/drm/drm_mipi_dsi.h |  2 ++
> >  2 files changed, 44 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> > index da34469b9b98..226822a44457 100644
> > --- a/drivers/gpu/drm/drm_mipi_dsi.c
> > +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> > @@ -553,6 +553,27 @@ int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device 
> > *dsi, u8 *mode)
> >  EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode);
> >
> >  /**
> > + * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB 
> > image
> > + *data used by the interface
> > + * @dsi: DSI peripheral device
> > + * @format: return location for the pixel format
> > + *
> > + * Return: 0 on success or a negative error code on failure.
> > + */
> > +int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format)
> > +{
> > +   ssize_t err;
> > +
> > +   err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format,
> > +   sizeof(*format));
> > +   if (err < 0)
> > +   return err;
> 
> This should probably return -ENODATA when err != sizeof(*format), like
> the previous patch did.

Done.

> It might be worth moving that logic into mipi_dsi_dcs_read, assuming
> we're not interested in partial data.

Agreed. I think we can leave that for a subsequent refactoring once
these function have matured a bit more and patterns appear.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 



[PATCH v4 13/16] drm/dsi: Implement DCS {get, set}_pixel_format commands

2014-11-03 Thread Sean Paul
On Mon, Nov 3, 2014 at 4:13 AM, Thierry Reding  
wrote:
> From: Thierry Reding 
>
> Provide small convenience wrappers to query or set the pixel format used
> by the interface.
>
> Signed-off-by: Thierry Reding 
> ---
>  drivers/gpu/drm/drm_mipi_dsi.c | 42 
> ++
>  include/drm/drm_mipi_dsi.h |  2 ++
>  2 files changed, 44 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index da34469b9b98..226822a44457 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -553,6 +553,27 @@ int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device 
> *dsi, u8 *mode)
>  EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode);
>
>  /**
> + * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
> + *data used by the interface
> + * @dsi: DSI peripheral device
> + * @format: return location for the pixel format
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format)
> +{
> +   ssize_t err;
> +
> +   err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format,
> +   sizeof(*format));
> +   if (err < 0)
> +   return err;

This should probably return -ENODATA when err != sizeof(*format), like
the previous patch did.

It might be worth moving that logic into mipi_dsi_dcs_read, assuming
we're not interested in partial data.

Sean



> +
> +   return 0;
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format);
> +
> +/**
>   * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside 
> the
>   *display module except interface communication
>   * @dsi: DSI peripheral device
> @@ -670,6 +691,27 @@ int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
>  }
>  EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on);
>
> +/**
> + * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image
> + *data used by the interface
> + * @dsi: DSI peripheral device
> + * @format: pixel format
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format)
> +{
> +   ssize_t err;
> +
> +   err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, ,
> +sizeof(format));
> +   if (err < 0)
> +   return err;
> +
> +   return 0;
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
> +
>  static int mipi_dsi_drv_probe(struct device *dev)
>  {
> struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
> diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> index 4cbf8e658a3a..415d01f90086 100644
> --- a/include/drm/drm_mipi_dsi.h
> +++ b/include/drm/drm_mipi_dsi.h
> @@ -197,6 +197,7 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 
> cmd, void *data,
>  int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
> +int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format);
>  int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi);
> @@ -204,6 +205,7 @@ int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device 
> *dsi);
>  int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
>  int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
>  enum mipi_dsi_dcs_tear_mode mode);
> +int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
>
>  /**
>   * struct mipi_dsi_driver - DSI driver
> --
> 2.1.2
>


[PATCH v4 13/16] drm/dsi: Implement DCS {get, set}_pixel_format commands

2014-11-03 Thread Thierry Reding
From: Thierry Reding 

Provide small convenience wrappers to query or set the pixel format used
by the interface.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_mipi_dsi.c | 42 ++
 include/drm/drm_mipi_dsi.h |  2 ++
 2 files changed, 44 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index da34469b9b98..226822a44457 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -553,6 +553,27 @@ int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device 
*dsi, u8 *mode)
 EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode);

 /**
+ * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
+ *data used by the interface
+ * @dsi: DSI peripheral device
+ * @format: return location for the pixel format
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format)
+{
+   ssize_t err;
+
+   err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format,
+   sizeof(*format));
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format);
+
+/**
  * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the
  *display module except interface communication
  * @dsi: DSI peripheral device
@@ -670,6 +691,27 @@ int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
 }
 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on);

+/**
+ * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image
+ *data used by the interface
+ * @dsi: DSI peripheral device
+ * @format: pixel format
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format)
+{
+   ssize_t err;
+
+   err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, ,
+sizeof(format));
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);
+
 static int mipi_dsi_drv_probe(struct device *dev)
 {
struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 4cbf8e658a3a..415d01f90086 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -197,6 +197,7 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 
cmd, void *data,
 int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
+int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format);
 int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi);
@@ -204,6 +205,7 @@ int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device 
*dsi);
 int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
 enum mipi_dsi_dcs_tear_mode mode);
+int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);

 /**
  * struct mipi_dsi_driver - DSI driver
-- 
2.1.2