Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCHv3 09/10] fbdev: ssd1307fb: Add sysfs handles to expose contrast and dim setting to userspace.
From: Thomas Niederprüm @ 2015-03-09 22:22 UTC (permalink / raw)
  To: plagnioj, tomi.valkeinen, maxime.ripard, kernel, shawn.guo,
	robh+dt
  Cc: linux-fbdev, linux-kernel, Thomas Niederprüm
In-Reply-To: <1425939732-18386-1-git-send-email-niederp@physik.uni-kl.de>

This patch adds sysfs handles to enable userspace control over the display
contrast as well as the dim mode. The handles are available as "contrast"
and "dim" in the framebuffers sysfs domain.

Signed-off-by: Thomas Niederprüm <niederp@physik.uni-kl.de>
---
 drivers/video/fbdev/ssd1307fb.c | 90 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 3cf4da1..fee6324 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -33,6 +33,7 @@
 #define SSD1307FB_CONTRAST		0x81
 #define	SSD1307FB_CHARGE_PUMP		0x8d
 #define SSD1307FB_SEG_REMAP_ON		0xa1
+#define SSD1307FB_DISPLAY_DIM		0xac
 #define SSD1307FB_DISPLAY_OFF		0xae
 #define SSD1307FB_SET_MULTIPLEX_RATIO	0xa8
 #define SSD1307FB_DISPLAY_ON		0xaf
@@ -43,6 +44,9 @@
 #define	SSD1307FB_SET_COM_PINS_CONFIG	0xda
 #define	SSD1307FB_SET_VCOMH		0xdb
 
+#define MIN_CONTRAST 0
+#define MAX_CONTRAST 255
+
 #define REFRASHRATE 1
 #define BITSPERPIXEL 1
 
@@ -73,6 +77,7 @@ struct ssd1307fb_par {
 	u32 dclk_div;
 	u32 dclk_frq;
 	struct ssd1307fb_deviceinfo *device_info;
+	u32 dim;
 	struct i2c_client *client;
 	u32 height;
 	struct fb_info *info;
@@ -476,6 +481,87 @@ static const struct of_device_id ssd1307fb_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ssd1307fb_of_match);
 
+static ssize_t show_contrast(struct device *device,
+			   struct device_attribute *attr, char *buf)
+{
+	struct fb_info *info = dev_get_drvdata(device);
+	struct ssd1307fb_par *par = info->par;
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", par->contrast);
+}
+
+static ssize_t store_contrast(struct device *device,
+			    struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	struct fb_info *info = dev_get_drvdata(device);
+	struct ssd1307fb_par *par = info->par;
+	unsigned long contrastval;
+	int ret;
+
+	ret = kstrtoul(buf, 0, &contrastval);
+	if (ret < 0)
+		return ret;
+
+	par->contrast = max_t(ulong, min_t(ulong, contrastval,
+		(ulong)MAX_CONTRAST), (ulong)MIN_CONTRAST);
+
+	ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST);
+	ret = ret & ssd1307fb_write_cmd(par->client, par->contrast);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+
+static ssize_t show_dim(struct device *device,
+			   struct device_attribute *attr, char *buf)
+{
+	struct fb_info *info = dev_get_drvdata(device);
+	struct ssd1307fb_par *par = info->par;
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", par->dim);
+}
+
+static ssize_t store_dim(struct device *device,
+			    struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	struct fb_info *info = dev_get_drvdata(device);
+	struct ssd1307fb_par *par = info->par;
+	unsigned long dimval;
+	int ret;
+
+	ret = kstrtoul(buf, 0, &dimval);
+	if (ret < 0)
+		return ret;
+
+	par->dim = max_t(ulong, min_t(ulong, dimval, (ulong)1), (ulong)0);
+	if (par->dim)
+		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_DIM);
+	else
+		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(contrast, S_IRUGO|S_IWUSR, show_contrast, store_contrast);
+static DEVICE_ATTR(dim, S_IRUGO|S_IWUSR, show_dim, store_dim);
+
+static struct attribute *panel_attrs[] = {
+		&dev_attr_contrast.attr,
+		&dev_attr_dim.attr,
+		NULL,
+};
+
+static struct attribute_group brightness_attr_grp = {
+		.name  = "brightness",
+		.attrs = panel_attrs,
+};
+
 static int ssd1307fb_probe(struct i2c_client *client,
 			   const struct i2c_device_id *id)
 {
@@ -614,6 +700,10 @@ static int ssd1307fb_probe(struct i2c_client *client,
 		goto panel_init_error;
 	}
 
+	ret = sysfs_create_group(&info->dev->kobj, &brightness_attr_grp);
+	if (ret)
+		dev_err(&client->dev, "Couldn't register sysfs nodes\n");
+
 	dev_info(&client->dev, "fb%d: %s framebuffer device registered, using %d bytes of video memory\n", info->node, info->fix.id, vmem_size);
 
 	return 0;
-- 
2.3.0


^ permalink raw reply related

* [PATCHv3 10/10] fbdev: ssd1307fb: Turn off display on driver unload.
From: Thomas Niederprüm @ 2015-03-09 22:22 UTC (permalink / raw)
  To: plagnioj, tomi.valkeinen, maxime.ripard, kernel, shawn.guo,
	robh+dt
  Cc: linux-fbdev, linux-kernel, Thomas Niederprüm
In-Reply-To: <1425939732-18386-1-git-send-email-niederp@physik.uni-kl.de>

This patch turns off the display when the driver is unloaded.

Signed-off-by: Thomas Niederprüm <niederp@physik.uni-kl.de>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/video/fbdev/ssd1307fb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index fee6324..5efed67 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -726,6 +726,8 @@ static int ssd1307fb_remove(struct i2c_client *client)
 	struct fb_info *info = i2c_get_clientdata(client);
 	struct ssd1307fb_par *par = info->par;
 
+	ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF);
+
 	unregister_framebuffer(info);
 	if (par->device_info->device_id = DEVID_SSD1307) {
 		pwm_disable(par->pwm);
-- 
2.3.0


^ permalink raw reply related

* Re: [PATCH] staging: sm750fb: Fix sparse warning
From: Dan Carpenter @ 2015-03-10  7:00 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: sudipm.mukherjee, teddy.wang, gregkh, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <1425934628-3717-1-git-send-email-lstoakes@gmail.com>

On Mon, Mar 09, 2015 at 08:57:08PM +0000, Lorenzo Stoakes wrote:
> This patch fixes the following sparse warning:-
> 
> drivers/staging/sm750fb/ddk750_help.c: warning: incorrect type in assignment (different address spaces)
> 
> Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
> ---
>  drivers/staging/sm750fb/ddk750_chip.h | 4 +++-
>  drivers/staging/sm750fb/ddk750_help.c | 2 +-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
> index 1c78875..a4e5bcc 100644
> --- a/drivers/staging/sm750fb/ddk750_chip.h
> +++ b/drivers/staging/sm750fb/ddk750_chip.h
> @@ -3,6 +3,8 @@
>  #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
>  #define SM750LE_REVISION_ID (char)0xfe
>  
> +#include <asm/io.h>
> +
>  /* This is all the chips recognized by this library */
>  typedef enum _logical_chip_type_t
>  {
> @@ -70,7 +72,7 @@ logical_chip_type_t getChipType(void);
>  unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
>  unsigned int calcPllValue2(unsigned int,pll_value_t *);
>  unsigned int formatPllReg(pll_value_t *pPLL);
> -void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
> +void ddk750_set_mmio(volatile unsigned char __iomem *,unsigned short,char);

No need for the volatile.  Really mmio750 should be a "void __iomem *"
it is declared as "unsigned char __iomem *" but it's not a char pointer
that's only to make the pointer math work.  It would work just as well
as a void and we could remove some ugly casting.

regards,
dan carpenter


^ permalink raw reply

* Re: [PATCH] staging: sm750fb: Fix sparse warning
From: Sudip Mukherjee @ 2015-03-10  7:54 UTC (permalink / raw)
  To: Lorenzo Stoakes; +Cc: teddy.wang, gregkh, linux-fbdev, devel, linux-kernel
In-Reply-To: <1425934628-3717-1-git-send-email-lstoakes@gmail.com>

On Mon, Mar 09, 2015 at 08:57:08PM +0000, Lorenzo Stoakes wrote:
>  
> +#include <asm/io.h>
> +
apart from what Dan Carpenter has said,
this is introducing one checkpatch warning, better to use #include <linux/io.h>
checkpatch is also giving warning about your patch subject

only one concern - if Greg first applies the patches i sent yesterday then this patch will not apply, and if this one is applied first then my series will not apply ...

regards
sudip

>  /* This is all the chips recognized by this library */
>  	mmio750 = addr;
>  	devId750 = devId;
> -- 
> 2.3.2
> 

^ permalink raw reply

* Re: [PATCH] staging: sm750fb: Fix sparse warning
From: Lorenzo Stoakes @ 2015-03-10  8:44 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: teddy.wang, Greg KH, linux-fbdev, devel, linux-kernel
In-Reply-To: <20150310074226.GA12561@sudip-PC>

On 10 March 2015 at 07:42, Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> only one concern - if Greg first applies the patches i sent yesterday then this patch will not apply, and if this one is applied first then my series will not apply ...

Indeed, I am more than happy to adapt the patch as required if your
patch series is applied first, I will keep an eye out for this,
additionally if you ping me if this occurs I will fix it right away.

Best,

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* Re: [PATCH] staging: sm750fb: Fix sparse warning
From: Lorenzo Stoakes @ 2015-03-10  8:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudip Mukherjee, teddy.wang, Greg KH, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <20150310070014.GM10964@mwanda>

On 10 March 2015 at 07:00, Dan Carpenter <dan.carpenter@oracle.com> wrote:

> No need for the volatile.

Will remove.

> Really mmio750 should be a "void __iomem *"
> it is declared as "unsigned char __iomem *" but it's not a char pointer
> that's only to make the pointer math work.  It would work just as well
> as a void and we could remove some ugly casting.

I'm thinking the change to "void __iomem *" from "unsigned char
__iomem *" ought to be a separate patch in order to keep this cleanly
focused on solving the sparse warning? Am more than happy to do this
and make the appropriate changes to the macros in ddk750_help.h.

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* [PATCH v2] staging: sm750fb: Fix sparse warning
From: Lorenzo Stoakes @ 2015-03-10  8:51 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh
  Cc: linux-fbdev, devel, linux-kernel, Lorenzo Stoakes

This patch fixes the following sparse warning:-

drivers/staging/sm750fb/ddk750_help.c: warning: incorrect type in assignment (different address spaces)

In addition it eliminates an unnecessary volatile.

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
 drivers/staging/sm750fb/ddk750_chip.h | 4 +++-
 drivers/staging/sm750fb/ddk750_help.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
index 1c78875..a4e5bcc 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -3,6 +3,8 @@
 #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
 #define SM750LE_REVISION_ID (char)0xfe
 
+#include <linux/io.h>
+
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
 {
@@ -70,7 +72,7 @@ logical_chip_type_t getChipType(void);
 unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
 unsigned int calcPllValue2(unsigned int,pll_value_t *);
 unsigned int formatPllReg(pll_value_t *pPLL);
-void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
+void ddk750_set_mmio(unsigned char __iomem *,unsigned short,char);
 unsigned int ddk750_getVMSize(void);
 int ddk750_initHw(initchip_param_t *);
 unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
diff --git a/drivers/staging/sm750fb/ddk750_help.c b/drivers/staging/sm750fb/ddk750_help.c
index cc00d2b..6ad4dec 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -7,7 +7,7 @@ char revId750 = 0;
 unsigned short devId750 = 0;
 
 /* after driver mapped io registers, use this function first */
-void ddk750_set_mmio(volatile unsigned char * addr,unsigned short devId,char revId)
+void ddk750_set_mmio(unsigned char __iomem * addr,unsigned short devId,char revId)
 {
 	mmio750 = addr;
 	devId750 = devId;
-- 
2.3.2


^ permalink raw reply related

* [PATCH v3 1/5] staging: sm750fb: wrong type for print
From: Sudip Mukherjee @ 2015-03-10  8:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-fbdev, devel, linux-kernel, Sudip Mukherjee

mention correct format specifier while printing.
fixes all the build warnings about incorrect argument type while
printing.
since this is a framebuffer device and it should follow what the
framebuffer layer is suggesting in struct fb_fix_screeninfo at
smem_start and mmio_start, so accordingly changed the datatypes of
vidmem_start, vidreg_start, vidmem_size and vidreg_size.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v3: changed the commit log.
v2: changed datatypes of vidmem_size and vidreg_size.

this patch will give checkpatch warnings about use of printk.
this patch was mainly to fix the build warnings. printk will be
converted to pr_* and dev_* in a later patch.

 drivers/staging/sm750fb/sm750.c    | 24 ++++++++++++------------
 drivers/staging/sm750fb/sm750.h    |  8 ++++----
 drivers/staging/sm750fb/sm750_hw.c |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 520c69e..753869e 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -530,20 +530,20 @@ static int lynxfb_ops_mmap(struct fb_info * info, struct vm_area_struct * vma)
 	if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
 		return -EINVAL;
 	off = vma->vm_pgoff << PAGE_SHIFT;
-	printk("lynxfb mmap pgoff: %x\n", vma->vm_pgoff);
-	printk("lynxfb mmap off 1: %x\n", off);
+	printk("lynxfb mmap pgoff: %lx\n", vma->vm_pgoff);
+	printk("lynxfb mmap off 1: %lx\n", off);
 	
 	/* frame buffer memory */
 	start = info->fix.smem_start;
 	len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len);
 	
-	printk("lynxfb mmap start 1: %x\n", start);
+	printk("lynxfb mmap start 1: %lx\n", start);
 	printk("lynxfb mmap len 1: %x\n", len);
 	
 	if (off >= len) {
 		/* memory mapped io */
 		off -= len;
-		printk("lynxfb mmap off 2: %x\n", off);
+		printk("lynxfb mmap off 2: %lx\n", off);
 		if (info->var.accel_flags) {
 			printk("lynxfb mmap accel flags true");
 			return -EINVAL;
@@ -551,28 +551,28 @@ static int lynxfb_ops_mmap(struct fb_info * info, struct vm_area_struct * vma)
 		start = info->fix.mmio_start;
 		len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len);
 		
-		printk("lynxfb mmap start 2: %x\n", start);
+		printk("lynxfb mmap start 2: %lx\n", start);
 		printk("lynxfb mmap len 2: %x\n", len);
 	}
 	start &= PAGE_MASK;
-	printk("lynxfb mmap start 3: %x\n", start);
-	printk("lynxfb mmap vm start: %x\n", vma->vm_start);
-	printk("lynxfb mmap vm end: %x\n", vma->vm_end);
+	printk("lynxfb mmap start 3: %lx\n", start);
+	printk("lynxfb mmap vm start: %lx\n", vma->vm_start);
+	printk("lynxfb mmap vm end: %lx\n", vma->vm_end);
 	printk("lynxfb mmap len: %x\n", len);
-	printk("lynxfb mmap off: %x\n", off);
+	printk("lynxfb mmap off: %lx\n", off);
 	if ((vma->vm_end - vma->vm_start + off) > len)
 	{
 		return -EINVAL;
 	}
 	off += start;
-	printk("lynxfb mmap off 3: %x\n", off);
+	printk("lynxfb mmap off 3: %lx\n", off);
 	vma->vm_pgoff = off >> PAGE_SHIFT;
 	/* This is an IO map - tell maydump to skip this VMA */
 	vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
 	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
 	fb_pgprotect(file, vma, off);
-	printk("lynxfb mmap off 4: %x\n", off);
-	printk("lynxfb mmap pgprot: %x\n", vma->vm_page_prot);
+	printk("lynxfb mmap off 4: %lx\n", off);
+	printk("lynxfb mmap pgprot: %lx\n", (unsigned long) pgprot_val(vma->vm_page_prot));
 	if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
 			     vma->vm_end - vma->vm_start, vma->vm_page_prot))
 		return -EAGAIN;
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index 711676c..d39968c 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -59,10 +59,10 @@ struct lynx_share{
 		}mtrr;
 #endif
 	/* all smi graphic adaptor got below attributes */
-	resource_size_t vidmem_start;
-	resource_size_t vidreg_start;
-	resource_size_t vidmem_size;
-	resource_size_t vidreg_size;
+	unsigned long vidmem_start;
+	unsigned long vidreg_start;
+	__u32 vidmem_size;
+	__u32 vidreg_size;
 	volatile unsigned char __iomem * pvReg;
 	unsigned char __iomem * pvMem;
 	/* locks*/
diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
index cd971bd..ec2d499 100644
--- a/drivers/staging/sm750fb/sm750_hw.c
+++ b/drivers/staging/sm750fb/sm750_hw.c
@@ -36,7 +36,7 @@ int hw_sm750_map(struct lynx_share* share,struct pci_dev* pdev)
 	share->vidreg_start  = pci_resource_start(pdev,1);
 	share->vidreg_size = MB(2);
 
-	pr_info("mmio phyAddr = %x\n",share->vidreg_start);
+	pr_info("mmio phyAddr = %lx\n", share->vidreg_start);
 
 	/* reserve the vidreg space of smi adaptor
 	 * if you do this, u need to add release region code
@@ -73,7 +73,7 @@ int hw_sm750_map(struct lynx_share* share,struct pci_dev* pdev)
 	 * @hw_sm750_getVMSize function can be safe.
 	 * */
 	share->vidmem_size = hw_sm750_getVMSize(share);
-	pr_info("video memory phyAddr = %x, size = %d bytes\n",
+	pr_info("video memory phyAddr = %lx, size = %u bytes\n",
 	share->vidmem_start,share->vidmem_size);
 
 	/* reserve the vidmem space of smi adaptor */
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH v3 2/5] staging: sm750fb: remove pragma optimize
From: Sudip Mukherjee @ 2015-03-10  8:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-fbdev, devel, linux-kernel, Sudip Mukherjee
In-Reply-To: <1425977139-25285-1-git-send-email-sudipm.mukherjee@gmail.com>

remove use of #pragma optimize which will usually be ignored by the
compiler.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v3: no change
v2: no change

 drivers/staging/sm750fb/ddk750_swi2c.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c
index b53407b..cae6b9b 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.c
+++ b/drivers/staging/sm750fb/ddk750_swi2c.c
@@ -217,8 +217,6 @@ static unsigned char swI2CReadSDA(void)
         return 0;
 }
 
-#pragma optimize( "", off )
-
 /*
  *  This function sends ACK signal
  */
@@ -356,7 +354,6 @@ unsigned char swI2CReadByte(unsigned char ack)
 
     return data;
 }
-#pragma optimize( "", on )
 
 /*
  * This function initializes GPIO port for SW I2C communication.
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH v3 3/5] staging: sm750fb: correctly define SM750LE_REVISION_ID
From: Sudip Mukherjee @ 2015-03-10  8:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-fbdev, devel, linux-kernel, Sudip Mukherjee
In-Reply-To: <1425977139-25285-1-git-send-email-sudipm.mukherjee@gmail.com>

check if it is already defined before defining SM750LE_REVISION_ID
again and at the same time mention correct data type.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v3: no change
v2: removed the redundant cast in sm750_hw.c

SM750LE_REVISION_ID is defined also in ddk750_chip.h.

 drivers/staging/sm750fb/ddk750_chip.h | 4 +++-
 drivers/staging/sm750fb/sm750_hw.c    | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
index 1c78875..d761b72 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -1,7 +1,9 @@
 #ifndef DDK750_CHIP_H__
 #define DDK750_CHIP_H__
 #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
-#define SM750LE_REVISION_ID (char)0xfe
+#ifndef SM750LE_REVISION_ID
+#define SM750LE_REVISION_ID ((unsigned char)0xfe)
+#endif
 
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
index ec2d499..a2b7fe2 100644
--- a/drivers/staging/sm750fb/sm750_hw.c
+++ b/drivers/staging/sm750fb/sm750_hw.c
@@ -277,7 +277,7 @@ int hw_sm750_crtc_checkMode(struct lynxfb_crtc* crtc,struct fb_var_screeninfo* v
 		case 16:
 			break;
 		case 32:
-			if(share->revid = (unsigned char)SM750LE_REVISION_ID){
+			if (share->revid = SM750LE_REVISION_ID) {
 				pr_debug("750le do not support 32bpp\n");
 				return -EINVAL;
 			}
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH v3 4/5] staging: sm750fb: fix undeclared function
From: Sudip Mukherjee @ 2015-03-10  8:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-fbdev, devel, linux-kernel, Sudip Mukherjee
In-Reply-To: <1425977139-25285-1-git-send-email-sudipm.mukherjee@gmail.com>

kbuild test robot reported that for microblaze-allyesconfig
chan_to_field() and lynxfb_ops_set_par() were not defined. These two
functions were defined under CONFIG_PM, so for any archtecture if
CONFIG_PM is not defined we will have this error.

while moving the lynxfb_suspend() function some very obvious
checkpatch errors, like space after comma, space after if, space
before opening brace, were taken care of.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v3: no change
v2: some extra spaces in the comments were removed.

 drivers/staging/sm750fb/sm750.c | 110 +++++++++++++++++++---------------------
 1 file changed, 53 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 753869e..476dc5c 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -303,62 +303,6 @@ static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
     return ret;
 }
 
-
-
-
-#ifdef CONFIG_PM
-static int lynxfb_suspend(struct pci_dev * pdev,pm_message_t mesg)
-{
-	struct fb_info * info;
-	struct lynx_share * share;
-	int ret;
-	
-
-	if(mesg.event = pdev->dev.power.power_state.event)
-		return 0;
-
-	ret = 0;
-	share = pci_get_drvdata(pdev);
-	switch (mesg.event) {
-	case PM_EVENT_FREEZE:
-	case PM_EVENT_PRETHAW:
-		pdev->dev.power.power_state = mesg;
-		return 0;
-	}
-
-	console_lock();
-	if (mesg.event & PM_EVENT_SLEEP) {
-		info = share->fbinfo[0];
-		if(info)
-			fb_set_suspend(info, 1);/* 1 means do suspend*/
-
-		info = share->fbinfo[1];
-		if(info)
-			fb_set_suspend(info, 1);/* 1 means do suspend*/
-
-		ret = pci_save_state(pdev);
-		if(ret){
-			pr_err("error:%d occured in pci_save_state\n",ret);
-			return ret;
-		}
-
-		/* set chip to sleep mode	*/
-		if(share->suspend)
-			(*share->suspend)(share);
-
-		pci_disable_device(pdev);
-		ret = pci_set_power_state(pdev,pci_choose_state(pdev,mesg));
-		if(ret){
-			pr_err("error:%d occured in pci_set_power_state\n",ret);
-			return ret;
-		}
-	}
-
-	pdev->dev.power.power_state = mesg;
-	console_unlock();
-	return ret;
-}
-
 static int lynxfb_ops_set_par(struct fb_info * info)
 {
 	struct lynxfb_par * par;
@@ -369,7 +313,6 @@ static int lynxfb_ops_set_par(struct fb_info * info)
 	struct fb_fix_screeninfo * fix;
 	int ret;
 	unsigned int line_length;
-	
 
 	if(!info)
 		return -EINVAL;
@@ -441,6 +384,7 @@ static int lynxfb_ops_set_par(struct fb_info * info)
 		ret = output->proc_setMode(output,var,fix);
 	return ret;
 }
+
 static inline unsigned int chan_to_field(unsigned int chan,struct fb_bitfield * bf)
 {
 	chan &= 0xffff;
@@ -448,6 +392,58 @@ static inline unsigned int chan_to_field(unsigned int chan,struct fb_bitfield *
 	return chan << bf->offset;
 }
 
+#ifdef CONFIG_PM
+static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
+{
+	struct fb_info *info;
+	struct lynx_share *share;
+	int ret;
+
+	if (mesg.event = pdev->dev.power.power_state.event)
+		return 0;
+
+	ret = 0;
+	share = pci_get_drvdata(pdev);
+	switch (mesg.event) {
+	case PM_EVENT_FREEZE:
+	case PM_EVENT_PRETHAW:
+		pdev->dev.power.power_state = mesg;
+		return 0;
+	}
+
+	console_lock();
+	if (mesg.event & PM_EVENT_SLEEP) {
+		info = share->fbinfo[0];
+		if (info)
+			/* 1 means do suspend*/
+			fb_set_suspend(info, 1);
+		info = share->fbinfo[1];
+		if (info)
+			/* 1 means do suspend*/
+			fb_set_suspend(info, 1);
+
+		ret = pci_save_state(pdev);
+		if (ret) {
+			pr_err("error:%d occurred in pci_save_state\n", ret);
+			return ret;
+		}
+
+		/* set chip to sleep mode*/
+		if (share->suspend)
+			(*share->suspend)(share);
+
+		pci_disable_device(pdev);
+		ret = pci_set_power_state(pdev, pci_choose_state(pdev, mesg));
+		if (ret) {
+			pr_err("error:%d occurred in pci_set_power_state\n", ret);
+			return ret;
+		}
+	}
+
+	pdev->dev.power.power_state = mesg;
+	console_unlock();
+	return ret;
+}
 
 static int lynxfb_resume(struct pci_dev* pdev)
 {
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH v3 5/5] staging: sm750fb: fix build failure
From: Sudip Mukherjee @ 2015-03-10  8:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-fbdev, devel, linux-kernel, Sudip Mukherjee
In-Reply-To: <1425977139-25285-1-git-send-email-sudipm.mukherjee@gmail.com>

for powerpc-allyesconfig build failed with an error of g_option
undeclared. we will get this error on all architecture if MODULE is
not defined. fixed the declaration of g_option.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v3: new entry in the series, it was not there till v2.

 drivers/staging/sm750fb/sm750.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 476dc5c..8c260ee 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -54,9 +54,7 @@ static const char * g_fbmode[] = {NULL,NULL};
 static const char * g_def_fbmode = "800x600-16@60";
 static char * g_settings = NULL;
 static int g_dualview = 0;
-#ifdef MODULE
 static char * g_option = NULL;
-#endif
 
 /* if not use spin_lock,system will die if user load driver
  * and immediatly unload driver frequently (dual)*/
-- 
1.8.1.2


^ permalink raw reply related

* Re: [PATCH] staging: sm750fb: Fix sparse warning
From: Dan Carpenter @ 2015-03-10  8:59 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Sudip Mukherjee, teddy.wang, Greg KH, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <CAA5enKa5x5R2Z9+Sc4UzKFu+N9rKoh_sW7hfVN8CmmqhF9LMiw@mail.gmail.com>

On Tue, Mar 10, 2015 at 08:47:47AM +0000, Lorenzo Stoakes wrote:
> On 10 March 2015 at 07:00, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> > No need for the volatile.
> 
> Will remove.
> 
> > Really mmio750 should be a "void __iomem *"
> > it is declared as "unsigned char __iomem *" but it's not a char pointer
> > that's only to make the pointer math work.  It would work just as well
> > as a void and we could remove some ugly casting.
> 
> I'm thinking the change to "void __iomem *" from "unsigned char
> __iomem *" ought to be a separate patch in order to keep this cleanly
> focused on solving the sparse warning? Am more than happy to do this
> and make the appropriate changes to the macros in ddk750_help.h.
> 

The patch is:

[patch] cleanup the type of mmio750

silencing a Sparse warning is just a side benifit of using correct
data types.  The "one thing per patch" rule also means that you should
fix a whole problem instead of half a thing per patch.

regards,
dan carpenter


^ permalink raw reply

* Re: [PATCH] staging: sm750fb: Fix sparse warning
From: Lorenzo Stoakes @ 2015-03-10  9:14 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudip Mukherjee, teddy.wang, Greg KH, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <20150310085915.GB16501@mwanda>

On 10 March 2015 at 08:59, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The patch is:
>
> [patch] cleanup the type of mmio750
>
> silencing a Sparse warning is just a side benifit of using correct
> data types.  The "one thing per patch" rule also means that you should
> fix a whole problem instead of half a thing per patch.
>
> regards,
> dan carpenter
>

Sure, sorry saw the patch as purely a sparse fixup, will adapt to be
an overall mmio750 cleanup and resubmit!

Best,

-- 
Lorenzo Stoakes
https:/ljs.io

^ permalink raw reply

* [PATCH] staging: sm750fb: Cleanup the type of mmio750
From: Lorenzo Stoakes @ 2015-03-10  9:57 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh
  Cc: linux-fbdev, devel, linux-kernel, Lorenzo Stoakes

This patch assigns the more appropriate void* type to the mmio750 variable
eliminating an unnecessary volatile qualifier in the process. Additionally it
updates parameter types as necessary where those parameters interact with
mmio750 and removes unnecessary casts.

As a consequence, this patch fixes the following sparse warning:-

drivers/staging/sm750fb/ddk750_help.c:12:17: warning: incorrect type in assignment (different address spaces)

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>

---
 drivers/staging/sm750fb/ddk750_chip.h |  4 +++-
 drivers/staging/sm750fb/ddk750_help.c |  4 ++--
 drivers/staging/sm750fb/ddk750_help.h | 10 +++++-----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
index 1c78875..d067b06 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -3,6 +3,8 @@
 #define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
 #define SM750LE_REVISION_ID (char)0xfe
 
+#include <linux/io.h>
+
 /* This is all the chips recognized by this library */
 typedef enum _logical_chip_type_t
 {
@@ -70,7 +72,7 @@ logical_chip_type_t getChipType(void);
 unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
 unsigned int calcPllValue2(unsigned int,pll_value_t *);
 unsigned int formatPllReg(pll_value_t *pPLL);
-void ddk750_set_mmio(volatile unsigned char *,unsigned short,char);
+void ddk750_set_mmio(void __iomem *,unsigned short,char);
 unsigned int ddk750_getVMSize(void);
 int ddk750_initHw(initchip_param_t *);
 unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
diff --git a/drivers/staging/sm750fb/ddk750_help.c b/drivers/staging/sm750fb/ddk750_help.c
index cc00d2b..c68ff3b 100644
--- a/drivers/staging/sm750fb/ddk750_help.c
+++ b/drivers/staging/sm750fb/ddk750_help.c
@@ -2,12 +2,12 @@
 //#include "ddk750_chip.h"
 #include "ddk750_help.h"
 
-volatile unsigned char __iomem * mmio750 = NULL;
+void __iomem * mmio750 = NULL;
 char revId750 = 0;
 unsigned short devId750 = 0;
 
 /* after driver mapped io registers, use this function first */
-void ddk750_set_mmio(volatile unsigned char * addr,unsigned short devId,char revId)
+void ddk750_set_mmio(void __iomem * addr,unsigned short devId,char revId)
 {
 	mmio750 = addr;
 	devId750 = devId;
diff --git a/drivers/staging/sm750fb/ddk750_help.h b/drivers/staging/sm750fb/ddk750_help.h
index 4fc93b5..07c8264 100644
--- a/drivers/staging/sm750fb/ddk750_help.h
+++ b/drivers/staging/sm750fb/ddk750_help.h
@@ -12,14 +12,14 @@
 #if 0
 /* if 718 big endian turned on,be aware that don't use this driver for general use,only for ppc big-endian */
 #warning "big endian on target cpu and enable nature big endian support of 718 capability !"
-#define PEEK32(addr)  			__raw_readl((void __iomem *)(mmio750)+(addr))
-#define POKE32(addr,data) 		__raw_writel((data),(void __iomem*)(mmio750)+(addr))
+#define PEEK32(addr)  			__raw_readl(mmio750 + addr)
+#define POKE32(addr,data) 		__raw_writel(data, mmio750 + addr)
 #else /* software control endianess */
-#define PEEK32(addr) readl((addr)+mmio750)
-#define POKE32(addr,data) writel((data),(addr)+mmio750)
+#define PEEK32(addr) readl(addr + mmio750)
+#define POKE32(addr,data) writel(data, addr + mmio750)
 #endif
 
-extern volatile unsigned  char __iomem * mmio750;
+extern void __iomem * mmio750;
 extern char revId750;
 extern unsigned short devId750;
 #else
-- 
2.3.2


^ permalink raw reply related

* Re: [PATCH 5/8] fbdev: ssd1307fb: Add module parameter bitsperpixel.
From: Tomi Valkeinen @ 2015-03-10 10:45 UTC (permalink / raw)
  To: Maxime Ripard, Thomas Niederprüm; +Cc: linux-fbdev, plagnioj, linux-kernel
In-Reply-To: <20150214155415.GC25269@lukather>

[-- Attachment #1: Type: text/plain, Size: 1933 bytes --]

On 14/02/15 17:54, Maxime Ripard wrote:
> On Sat, Feb 07, 2015 at 05:05:03PM +0100, Thomas Niederprüm wrote:
>> Am Sat, 7 Feb 2015 12:20:43 +0100
>> schrieb Maxime Ripard <maxime.ripard@free-electrons.com>:
>>
>>> On Fri, Feb 06, 2015 at 11:28:11PM +0100, niederp@physik.uni-kl.de
>>> wrote:
>>>> From: Thomas Niederprüm <niederp@physik.uni-kl.de>
>>>>
>>>> This patch adds a module parameter 'bitsperpixel' to adjust the
>>>> colordepth of the framebuffer. All values >1 will result in memory
>>>> map of the requested color depth. However only the MSB of each
>>>> pixel will be sent to the device. The framebuffer identifies itself
>>>> as a grayscale display with the specified depth.
>>>
>>> I'm not sure this is the right thing to do.
>>>
>>> The bits per pixel for this display is rightfully defined, used and
>>> reported to the userspace, why would you want to change that?
>>
>> You are right of course. The display is 1bpp and it reports to be 1
>> bpp. The problem is that there is almost no userspace library that can
>> handle 1 bit framebuffers correctly. So it is nice if the framebuffer
>> (optionally) can expose itself as 8 bits per pixel grayscale to the
>> userspace program. As an example this allows to run DirectFB on the
>> framebuffer, which is not possible out of the box for 1bpp.
>>
>> Also note that if do not set the module parameter at load time
>> the framebuffer will be 1bpp. So you have to actively set that module
>> parameter to make the framebuffer pretend to be more than 1bpp.
>>
>> In any case I don't cling to that patch, I just thought it was a nice
>> feature.
> 
> I'd say that the right fix would be to patch DirectFB, instead of
> faking that in the kernel.
> 
> But again, that's probably Tomi's call, not mine.

Right, I'm not thrilled =). I don't think it's a good idea to lie to the
userspace (except when fixing regressions).

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH 7/8] fbdev: ssd1307fb: Add sysfs handles to expose contrast and dim setting to userspace.
From: Tomi Valkeinen @ 2015-03-10 10:49 UTC (permalink / raw)
  To: Maxime Ripard, Thomas Niederprüm; +Cc: linux-fbdev, plagnioj, linux-kernel
In-Reply-To: <20150209085239.GX2079@lukather>

[-- Attachment #1: Type: text/plain, Size: 1111 bytes --]

On 09/02/15 10:52, Maxime Ripard wrote:
> On Sat, Feb 07, 2015 at 05:42:44PM +0100, Thomas Niederprüm wrote:
>>>> +static struct device_attribute device_attrs[] = {
>>>> +	__ATTR(contrast, S_IRUGO|S_IWUSR, show_contrast,
>>>> store_contrast),
>>>> +	__ATTR(dim, S_IRUGO|S_IWUSR, show_dim, store_dim),
>>>> +
>>>> +};
>>>> +
>>>
>>> I would have thought this was something accessible through the
>>> framebuffer ioctl.
>>>
>>> Apparently it's not, at least for the contrast, so maybe it should be
>>> added there, instead of doing it for a single driver?
>>
>> I think the contrast setting for an OLED display is much like the
>> backlight setting for LCD panel. Since there is also no ioctl to set
>> the backlight of an LCD I wonder if the contrast of an OLED should have
>> one.
> 
> It's too much of framebuffer interface debate for me here. Tomi?

We have backlight and contrast already in backlight-class and lcd-class
(drivers/video/backlight/backlight.c and drivers/video/backlight/lcd.c).
Are those something that could be used here instead of custom sysfs files?

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH 4/8] fbdev: ssd1307fb: Use vmalloc to allocate video memory.
From: Tomi Valkeinen @ 2015-03-10 11:28 UTC (permalink / raw)
  To: Thomas Niederprüm, Maxime Ripard; +Cc: linux-fbdev, plagnioj, linux-kernel
In-Reply-To: <20150214152212.1643da7d@maestro.intranet>

[-- Attachment #1: Type: text/plain, Size: 2240 bytes --]

On 14/02/15 16:22, Thomas Niederprüm wrote:
> Am Thu, 12 Feb 2015 16:11:21 +0100
> schrieb Maxime Ripard <maxime.ripard@free-electrons.com>:
> 
>> On Sat, Feb 07, 2015 at 04:35:41PM +0100, Thomas Niederprüm wrote:
>>> Am Sat, 7 Feb 2015 12:18:21 +0100
>>> schrieb Maxime Ripard <maxime.ripard@free-electrons.com>:
>>>
>>>> Hi,
>>>>
>>>> On Fri, Feb 06, 2015 at 11:28:10PM +0100, niederp@physik.uni-kl.de
>>>> wrote:
>>>>> From: Thomas Niederprüm <niederp@physik.uni-kl.de>
>>>>>
>>>>> It makes sense to use vmalloc to allocate the video buffer
>>>>> since it has to be page aligned memory for using it with mmap.
>>>>
>>>> Please wrap your commit log at 80 chars.
>>>
>>> I'll try to do so in future, sorry for that.
>>>
>>>>
>>>> It looks like there's numerous fbdev drivers using this
>>>> (especially since you copy pasted that code, without mentionning
>>>> it).
>>>
>>> Yes, I should have mentioned that in the commit message. As
>>> implicitly indicated in the cover letter the rvmalloc() and
>>> rvfree() are copy pasted from the vfb driver. Honestly, I didn't
>>> give this one too much thought. It seemed a viable solution to the
>>> mmap problem. For a bit more history on that, see my comment below.
>>>
>>>>
>>>> That should be turned into an allocator so that drivers all get
>>>> this right.
>>>>
>>>>> Also deffered io seems buggy in combination with kmalloc'ed
>>>>> memory (crash on unloading the module).
>>>>
>>>> And maybe that's the real issue to fix.
>>>
>>> The problem is solved by using vmalloc ;)
>>
>> Yep, but why do you need to mark the reserved pages?
>>
>> ...
> 
> As far as I understood mmaped memory is marked as userspace memory in
> the page table and is therefore subject to swapping. The pages are
> marked reserved to make clear that this memory can not be swapped and
> thus lock the pages in memory. See discussions [0,1,2]. 

Why is it a problem if it is swapped? Only CPU uses the memory, as far
as I can see.

Also, isn't doing __pa() for the memory returned by vmalloc plain wrong?

What was the crash about when using kmalloc? It would be good to fix
defio, as I don't see why it should not work with kmalloced memory.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH] staging: sm750fb: Cleanup the type of mmio750
From: Dan Carpenter @ 2015-03-10 11:40 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: sudipm.mukherjee, teddy.wang, gregkh, devel, linux-fbdev,
	linux-kernel
In-Reply-To: <1425981426-20680-1-git-send-email-lstoakes@gmail.com>

On Tue, Mar 10, 2015 at 09:57:06AM +0000, Lorenzo Stoakes wrote:
> This patch assigns the more appropriate void* type to the mmio750 variable
> eliminating an unnecessary volatile qualifier in the process. Additionally it
> updates parameter types as necessary where those parameters interact with
> mmio750 and removes unnecessary casts.
> 
> As a consequence, this patch fixes the following sparse warning:-
> 
> drivers/staging/sm750fb/ddk750_help.c:12:17: warning: incorrect type in assignment (different address spaces)
> 
> Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>

Looks good.  Thanks for doing this.

regards,
dan carpenter


^ permalink raw reply

* Re: [PATCH v2] video: mxsfb: Make sure axi clock is enabled when accessing registers
From: Tomi Valkeinen @ 2015-03-10 12:02 UTC (permalink / raw)
  To: Liu Ying, linux-fbdev
  Cc: Peter Chen, Jean-Christophe Plagniol-Villard, Fabio Estevam,
	Greg Kroah-Hartman, linux-kernel, stable
In-Reply-To: <1425452771-19313-1-git-send-email-Ying.Liu@freescale.com>

[-- Attachment #1: Type: text/plain, Size: 4555 bytes --]

On 04/03/15 09:06, Liu Ying wrote:
> The LCDIF engines embedded in i.MX6sl and i.MX6sx SoCs need the axi clock
> as the engine's system clock.  The clock should be enabled when accessing
> LCDIF registers, otherwise the kernel would hang up.  We should also keep
> the clock being enabled when the engine is being active to scan out frames

The text above is a bit confusing. Maybe just "... also keep the clock
enabled when..."

> from memory.  This patch makes sure the axi clock is enabled when accessing
> registers so that the kernel hang up issue can be fixed.
> 
> Reported-by: Peter Chen <peter.chen@freescale.com>
> Tested-by: Peter Chen <peter.chen@freescale.com>
> Cc: <stable@vger.kernel.org> # 3.19+
> Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
> ---
> v1->v2:
> * Add 'Tested-by: Peter Chen <peter.chen@freescale.com>' tag.
> * Add 'Cc: <stable@vger.kernel.org> # 3.19+' tag.
> 
>  drivers/video/fbdev/mxsfb.c | 70 ++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 56 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
> index f8ac4a4..a8cf3b2 100644
> --- a/drivers/video/fbdev/mxsfb.c
> +++ b/drivers/video/fbdev/mxsfb.c
> @@ -316,6 +316,18 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var,
>  	return 0;
>  }
>  
> +static inline void mxsfb_enable_axi_clk(struct mxsfb_info *host)
> +{
> +	if (host->clk_axi)
> +		clk_prepare_enable(host->clk_axi);
> +}
> +
> +static inline void mxsfb_disable_axi_clk(struct mxsfb_info *host)
> +{
> +	if (host->clk_axi)
> +		clk_disable_unprepare(host->clk_axi);
> +}
> +
>  static void mxsfb_enable_controller(struct fb_info *fb_info)
>  {
>  	struct mxsfb_info *host = to_imxfb_host(fb_info);
> @@ -333,14 +345,13 @@ static void mxsfb_enable_controller(struct fb_info *fb_info)
>  		}
>  	}
>  
> -	if (host->clk_axi)
> -		clk_prepare_enable(host->clk_axi);
> -
>  	if (host->clk_disp_axi)
>  		clk_prepare_enable(host->clk_disp_axi);
>  	clk_prepare_enable(host->clk);
>  	clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U);
>  
> +	mxsfb_enable_axi_clk(host);
> +

Is there some reason to move the clk enable to a different place here?

>  	/* if it was disabled, re-enable the mode again */
>  	writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_SET);
>  
> @@ -380,11 +391,11 @@ static void mxsfb_disable_controller(struct fb_info *fb_info)
>  	reg = readl(host->base + LCDC_VDCTRL4);
>  	writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4);
>  
> +	mxsfb_disable_axi_clk(host);
> +
>  	clk_disable_unprepare(host->clk);
>  	if (host->clk_disp_axi)
>  		clk_disable_unprepare(host->clk_disp_axi);
> -	if (host->clk_axi)
> -		clk_disable_unprepare(host->clk_axi);

And same here for disable.

>  	host->enabled = 0;
>  
> @@ -421,6 +432,8 @@ static int mxsfb_set_par(struct fb_info *fb_info)
>  		mxsfb_disable_controller(fb_info);
>  	}
>  
> +	mxsfb_enable_axi_clk(host);
> +
>  	/* clear the FIFOs */
>  	writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET);
>  
> @@ -438,6 +451,7 @@ static int mxsfb_set_par(struct fb_info *fb_info)
>  		ctrl |= CTRL_SET_WORD_LENGTH(3);
>  		switch (host->ld_intf_width) {
>  		case STMLCDIF_8BIT:
> +			mxsfb_disable_axi_clk(host);
>  			dev_err(&host->pdev->dev,
>  					"Unsupported LCD bus width mapping\n");
>  			return -EINVAL;
> @@ -451,6 +465,7 @@ static int mxsfb_set_par(struct fb_info *fb_info)
>  		writel(CTRL1_SET_BYTE_PACKAGING(0x7), host->base + LCDC_CTRL1);
>  		break;
>  	default:
> +		mxsfb_disable_axi_clk(host);
>  		dev_err(&host->pdev->dev, "Unhandled color depth of %u\n",
>  				fb_info->var.bits_per_pixel);
>  		return -EINVAL;
> @@ -504,6 +519,8 @@ static int mxsfb_set_par(struct fb_info *fb_info)
>  			fb_info->fix.line_length * fb_info->var.yoffset,
>  			host->base + host->devdata->next_buf);
>  
> +	mxsfb_disable_axi_clk(host);
> +
>  	if (reenable)
>  		mxsfb_enable_controller(fb_info);
>  
> @@ -582,10 +599,16 @@ static int mxsfb_pan_display(struct fb_var_screeninfo *var,
>  
>  	offset = fb_info->fix.line_length * var->yoffset;
>  
> +	if (!host->enabled)
> +		mxsfb_enable_axi_clk(host);
> +
>  	/* update on next VSYNC */
>  	writel(fb_info->fix.smem_start + offset,
>  			host->base + host->devdata->next_buf);
>  
> +	if (!host->enabled)
> +		mxsfb_disable_axi_clk(host);
> +

Why do you check for host->enabled here, but not elsewhere?

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH,RESEND] framebuffer: don't link fb_devio into kernel image unconditionally
From: Tomi Valkeinen @ 2015-03-10 12:18 UTC (permalink / raw)
  To: linux-fbdev
In-Reply-To: <E1YSma9-0001JA-6C@stardust.g4.wien.funkfeuer.at>

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

On 03/03/15 15:09, Harald Geyer wrote:
> CONFIG_FB_DEFERRED_IO is defined as bool while CONFIG_FB is defined as
> tristate. Currently fb_defio.o is linked into the kernel image even if
> CONFIG_FB=m. 
> 
> I fix this by updating the Makefile to link fb_defio.o into fb.o and thus
> go into one place with the other core framebuffer code.
> 
> This has been tested on arm/sunxi and arm/mxs.
> 
> Signed-off-by: Harald Geyer <harald@ccbib.org>
> ---
> Resending this patch as I didn't get any reply for over two weeks.
> 
>  drivers/video/fbdev/core/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/video/fbdev/core/Makefile b/drivers/video/fbdev/core/Makefile
> index 67f28e2..23d86a8 100644
> --- a/drivers/video/fbdev/core/Makefile
> +++ b/drivers/video/fbdev/core/Makefile
> @@ -3,6 +3,7 @@ obj-$(CONFIG_FB_CMDLINE)          += fb_cmdline.o
>  obj-$(CONFIG_FB)                  += fb.o
>  fb-y                              := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
>                                       modedb.o fbcvt.o
> +fb-$(CONFIG_FB_DEFERRED_IO)       += fb_defio.o
>  fb-objs                           := $(fb-y)
>  
>  obj-$(CONFIG_FB_CFB_FILLRECT)  += cfbfillrect.o
> @@ -14,4 +15,3 @@ obj-$(CONFIG_FB_SYS_IMAGEBLIT) += sysimgblt.o
>  obj-$(CONFIG_FB_SYS_FOPS)      += fb_sys_fops.o
>  obj-$(CONFIG_FB_SVGALIB)       += svgalib.o
>  obj-$(CONFIG_FB_DDC)           += fb_ddc.o
> -obj-$(CONFIG_FB_DEFERRED_IO)   += fb_defio.o

I think this change makes sense. An alternative would be to make
fb_defio tristate, but as fb.ko uses fb_defio, fb_defio will always be
loaded if fb is used. And I don't think fb_defio.ko can be used alone,
without fb.ko.

But if you do link fb_defio into fb.ko, I think you need to remove
MODULE_LICENSE() from fb_defio.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH 03/15] fbdev: aty128fb: replace PPC_OF with PPC
From: Tomi Valkeinen @ 2015-03-10 12:23 UTC (permalink / raw)
  To: Kevin Hao, Benjamin Herrenschmidt
  Cc: linux-fbdev, Jean-Christophe Plagniol-Villard, linuxppc-dev,
	Paul Mackerras
In-Reply-To: <20150227010549.GA10596@pek-khao-d1.corp.ad.wrs.com>

[-- Attachment #1: Type: text/plain, Size: 999 bytes --]

On 27/02/15 03:05, Kevin Hao wrote:
> On Fri, Feb 27, 2015 at 11:11:15AM +1100, Benjamin Herrenschmidt wrote:
>> On Sat, 2015-01-31 at 21:47 +0800, Kevin Hao wrote:
>>> The PPC_OF is a ppc specific option which is used to mean that the
>>> firmware device tree access functions are available. Since all the
>>> ppc platforms have a device tree, it is aways set to 'y' for ppc.
>>> So it makes no sense to keep a such option in the current kernel.
>>> Replace it with PPC.
>>>
>>> Signed-off-by: Kevin Hao <haokexin@gmail.com>
>>
>> For this and generally the whole series,
>>
>> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> 
> Thanks Ben.
> 
>>
>> Which tree do we expect this to go through ?
> 
> I just sent out a v2 [1] a few hours earlier with some minor updates. We plan
> to merge this patch series via the powerpc tree in 4.1 cycle if I can collect
> all the acks from the corresponding driver maintainers.

Fbdev changes look ok to me.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH v2] video: fbdev: use msecs_to_jiffies for time conversions
From: Tomi Valkeinen @ 2015-03-10 12:32 UTC (permalink / raw)
  To: Nicholas Mc Guire, Jean-Christophe Plagniol-Villard
  Cc: Jingoo Han, Daniel Vetter, Fabian Frederick, Laurent Pinchart,
	Wolfram Sang, linux-fbdev, linux-kernel
In-Reply-To: <1424442841-25466-1-git-send-email-hofrat@osadl.org>

[-- Attachment #1: Type: text/plain, Size: 894 bytes --]

On 20/02/15 16:34, Nicholas Mc Guire wrote:
> This is only an API consolidation and should make things more readable by
> replacing  var * HZ / 1000  by msecs_to_jiffies(var).
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
> 
> v2: fixed missing closing parenthesis in pxafb_disable_controller.
>     Compile testing was missing part of the patched code due to
>     the missing CONFIG_FB_PXA_SMARTPANEL=y, so the missing closing
>     parenthesis reported by Tomi Valkeinen <tomi.valkeinen@ti.com>
>     pxafb_disable_controller went unnoticed.
> 
> Patch was only compile tested with viper_defconfig CONFIG_FB_PXA=m,
> CONFIG_FB_PXA_SMARTPANEL=y
> 
> Patch is against 3.19.0 (localversion-next is -next-20150220)
> 
>  drivers/video/fbdev/pxafb.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 

Thanks, queued for 4.1.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH 2/3 v3] hyperv: hyperv_fb.c: match wait_for_completion_timeout return type
From: Tomi Valkeinen @ 2015-03-10 12:38 UTC (permalink / raw)
  To: Nicholas Mc Guire, K. Y. Srinivasan
  Cc: Haiyang Zhang, Jean-Christophe Plagniol-Villard, devel,
	linux-fbdev, linux-kernel
In-Reply-To: <1422527056-24929-1-git-send-email-der.herr@hofr.at>

[-- Attachment #1: Type: text/plain, Size: 1678 bytes --]

On 29/01/15 12:24, Nicholas Mc Guire wrote:
> The return type of wait_for_completion_timeout is unsigned long not
> int. This patch fixes up the declarations only.
> 
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> ---
> 
> v2: fixed subject line
> v3: fixed patch description as recommended by Dan Carpenter
>     <dan.carpenter@oracle.com>
> 
> Patch was compile tested only for x86_64_defconfig + CONFIG_X86_VSMP=y
> CONFIG_HYPERV=m, CONFIG_FB_HYPERV=m
> 
> Patch is against 3.19.0-rc5 -next-20150123
> 
>  drivers/video/fbdev/hyperv_fb.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
> index 4254336..807ee22 100644
> --- a/drivers/video/fbdev/hyperv_fb.c
> +++ b/drivers/video/fbdev/hyperv_fb.c
> @@ -415,7 +415,8 @@ static int synthvid_negotiate_ver(struct hv_device *hdev, u32 ver)
>  	struct fb_info *info = hv_get_drvdata(hdev);
>  	struct hvfb_par *par = info->par;
>  	struct synthvid_msg *msg = (struct synthvid_msg *)par->init_buf;
> -	int t, ret = 0;
> +	int ret = 0;
> +	unsigned long t;
>  
>  	memset(msg, 0, sizeof(struct synthvid_msg));
>  	msg->vid_hdr.type = SYNTHVID_VERSION_REQUEST;
> @@ -488,7 +489,8 @@ static int synthvid_send_config(struct hv_device *hdev)
>  	struct fb_info *info = hv_get_drvdata(hdev);
>  	struct hvfb_par *par = info->par;
>  	struct synthvid_msg *msg = (struct synthvid_msg *)par->init_buf;
> -	int t, ret = 0;
> +	int ret = 0;
> +	unsigned long t;
>  
>  	/* Send VRAM location */
>  	memset(msg, 0, sizeof(struct synthvid_msg));
> 

Thanks, queued for 4.1.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [PATCH] video: treat signal like timeout as failure
From: Tomi Valkeinen @ 2015-03-10 12:43 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1421731430-13207-1-git-send-email-der.herr@hofr.at>

[-- Attachment #1: Type: text/plain, Size: 1232 bytes --]

On 20/01/15 07:23, Nicholas Mc Guire wrote:
> if(!wait_for_completion_interruptible_timeout(...))
> only handles the timeout case - this patch adds handling the
> signal case the same as timeout and cleans up.
> 
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> ---
> 
> Only the timeout case was being handled, return of 0 in 
> wait_for_completion_interruptible_timeout, the signal case (-ERESTARTSYS)
> was treated just like the case of successful completion, which is most 
> likely not reasonable.
> 
> Note that exynos_mipi_dsi_wr_data/exynos_mipi_dsi_rd_data return values
> are not checked at the call sites in s6e8ax0.c (cmd_read/cmd_write)!
> 
> This patch simply treats the signal case the same way as the timeout case,
> by releasing locks and returning 0 - which might not be the right thing to
> do - this needs a review by someone knowing the details of this driver.

While I agree that this patch is a bit better than the current state,
the code still looks wrong as Russell said.

I can merge this, but I'd rather have someone from Samsung look at the
code and change it to use wait_for_completion_killable_timeout() if
that's what this code is really supposed to use.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox