[PATCH 03/25] drm/fb_helper: Create wrappers for fb_sys_read/write funcs

2015-07-13 Thread Archit Taneja


On 07/13/2015 01:01 PM, Daniel Vetter wrote:
> On Mon, Jul 13, 2015 at 12:07:59PM +0530, Archit Taneja wrote:
>> Some drm drivers populate their fb_ops with fb_sys_read/write fb sysfs
>> ops.
>>
>> Create a drm_fb_helper function  that wraps around these calls.
>>
>> This is part of an effort to prevent drm drivers from calling fbdev
>> functions directly, in order to make fbdev emulation a top level drm
>> option.
>>
>> Signed-off-by: Archit Taneja 
>> ---
>>   drivers/gpu/drm/Kconfig |  1 +
>>   drivers/gpu/drm/drm_fb_helper.c | 20 
>>   include/drm/drm_fb_helper.h |  5 +
>>   3 files changed, 26 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> index a66ac44..b284cdc 100644
>> --- a/drivers/gpu/drm/Kconfig
>> +++ b/drivers/gpu/drm/Kconfig
>> @@ -37,6 +37,7 @@ config DRM_KMS_FB_HELPER
>>  select FB
>>  select FRAMEBUFFER_CONSOLE if !EXPERT
>>  select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
>> +select FB_SYS_FOPS
>>  help
>>FBDEV helpers for KMS drivers.
>>
>> diff --git a/drivers/gpu/drm/drm_fb_helper.c 
>> b/drivers/gpu/drm/drm_fb_helper.c
>> index 742377d..795547e 100644
>> --- a/drivers/gpu/drm/drm_fb_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>> @@ -744,6 +744,26 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
>> *fb_helper)
>>   }
>>   EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
>>
>> +ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
>> +size_t count, loff_t *ppos)
>> +{
>> +if (info)
>
> I think this check here can never fail (if there's no fbdev you can't call
> this function), I don't think we need it. Even for drivers which call this
> themselves (like qxl/udl) they only call it from fbdev code.

That's a good point. I'll remove the 'if (info)' check.

qxl/udl don't seem to call the fb sysfs funcs. So I think it's okay.

Archit

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH 03/25] drm/fb_helper: Create wrappers for fb_sys_read/write funcs

2015-07-13 Thread Archit Taneja
Some drm drivers populate their fb_ops with fb_sys_read/write fb sysfs
ops.

Create a drm_fb_helper function  that wraps around these calls.

This is part of an effort to prevent drm drivers from calling fbdev
functions directly, in order to make fbdev emulation a top level drm
option.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/Kconfig |  1 +
 drivers/gpu/drm/drm_fb_helper.c | 20 
 include/drm/drm_fb_helper.h |  5 +
 3 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index a66ac44..b284cdc 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -37,6 +37,7 @@ config DRM_KMS_FB_HELPER
select FB
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
+   select FB_SYS_FOPS
help
  FBDEV helpers for KMS drivers.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 742377d..795547e 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -744,6 +744,26 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
*fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);

+ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
+   size_t count, loff_t *ppos)
+{
+   if (info)
+   return fb_sys_read(info, buf, count, ppos);
+
+   return -ENODEV;
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_read);
+
+ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
+   size_t count, loff_t *ppos)
+{
+   if (info)
+   return fb_sys_write(info, buf, count, ppos);
+
+   return -ENODEV;
+}
+EXPORT_SYMBOL(drm_fb_helper_sys_write);
+
 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 u16 blue, u16 regno, struct fb_info *info)
 {
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 4c90837..f74e59e 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -147,6 +147,11 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t 
pitch,

 void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper);

+ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
+   size_t count, loff_t *ppos);
+ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
+   size_t count, loff_t *ppos);
+
 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);

 int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH 03/25] drm/fb_helper: Create wrappers for fb_sys_read/write funcs

2015-07-13 Thread Daniel Vetter
On Mon, Jul 13, 2015 at 12:07:59PM +0530, Archit Taneja wrote:
> Some drm drivers populate their fb_ops with fb_sys_read/write fb sysfs
> ops.
> 
> Create a drm_fb_helper function  that wraps around these calls.
> 
> This is part of an effort to prevent drm drivers from calling fbdev
> functions directly, in order to make fbdev emulation a top level drm
> option.
> 
> Signed-off-by: Archit Taneja 
> ---
>  drivers/gpu/drm/Kconfig |  1 +
>  drivers/gpu/drm/drm_fb_helper.c | 20 
>  include/drm/drm_fb_helper.h |  5 +
>  3 files changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index a66ac44..b284cdc 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -37,6 +37,7 @@ config DRM_KMS_FB_HELPER
>   select FB
>   select FRAMEBUFFER_CONSOLE if !EXPERT
>   select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
> + select FB_SYS_FOPS
>   help
> FBDEV helpers for KMS drivers.
>  
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 742377d..795547e 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -744,6 +744,26 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
> *fb_helper)
>  }
>  EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
>  
> +ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
> + size_t count, loff_t *ppos)

Another one: Checkpatch complains about alignment here. I agree.
-Danel

> +{
> + if (info)
> + return fb_sys_read(info, buf, count, ppos);
> +
> + return -ENODEV;
> +}
> +EXPORT_SYMBOL(drm_fb_helper_sys_read);
> +
> +ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
> + size_t count, loff_t *ppos)
> +{
> + if (info)
> + return fb_sys_write(info, buf, count, ppos);
> +
> + return -ENODEV;
> +}
> +EXPORT_SYMBOL(drm_fb_helper_sys_write);
> +
>  static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
>u16 blue, u16 regno, struct fb_info *info)
>  {
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 4c90837..f74e59e 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -147,6 +147,11 @@ void drm_fb_helper_fill_fix(struct fb_info *info, 
> uint32_t pitch,
>  
>  void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper);
>  
> +ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
> + size_t count, loff_t *ppos);
> +ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
> + size_t count, loff_t *ppos);
> +
>  int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
>  
>  int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> hosted by The Linux Foundation
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 03/25] drm/fb_helper: Create wrappers for fb_sys_read/write funcs

2015-07-13 Thread Daniel Vetter
On Mon, Jul 13, 2015 at 12:07:59PM +0530, Archit Taneja wrote:
> Some drm drivers populate their fb_ops with fb_sys_read/write fb sysfs
> ops.
> 
> Create a drm_fb_helper function  that wraps around these calls.
> 
> This is part of an effort to prevent drm drivers from calling fbdev
> functions directly, in order to make fbdev emulation a top level drm
> option.
> 
> Signed-off-by: Archit Taneja 
> ---
>  drivers/gpu/drm/Kconfig |  1 +
>  drivers/gpu/drm/drm_fb_helper.c | 20 
>  include/drm/drm_fb_helper.h |  5 +
>  3 files changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index a66ac44..b284cdc 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -37,6 +37,7 @@ config DRM_KMS_FB_HELPER
>   select FB
>   select FRAMEBUFFER_CONSOLE if !EXPERT
>   select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
> + select FB_SYS_FOPS
>   help
> FBDEV helpers for KMS drivers.
>  
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 742377d..795547e 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -744,6 +744,26 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper 
> *fb_helper)
>  }
>  EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
>  
> +ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
> + size_t count, loff_t *ppos)
> +{
> + if (info)

I think this check here can never fail (if there's no fbdev you can't call
this function), I don't think we need it. Even for drivers which call this
themselves (like qxl/udl) they only call it from fbdev code.
-Daniel

> + return fb_sys_read(info, buf, count, ppos);
> +
> + return -ENODEV;
> +}
> +EXPORT_SYMBOL(drm_fb_helper_sys_read);
> +
> +ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
> + size_t count, loff_t *ppos)
> +{
> + if (info)
> + return fb_sys_write(info, buf, count, ppos);
> +
> + return -ENODEV;
> +}
> +EXPORT_SYMBOL(drm_fb_helper_sys_write);
> +
>  static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
>u16 blue, u16 regno, struct fb_info *info)
>  {
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 4c90837..f74e59e 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -147,6 +147,11 @@ void drm_fb_helper_fill_fix(struct fb_info *info, 
> uint32_t pitch,
>  
>  void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper);
>  
> +ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
> + size_t count, loff_t *ppos);
> +ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
> + size_t count, loff_t *ppos);
> +
>  int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
>  
>  int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> hosted by The Linux Foundation
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch