Skip to content

Commit

Permalink
fbdev: detect primary display device
Browse files Browse the repository at this point in the history
Add function helper, fb_is_primary_device().  Given struct fb_info, it will
return a nonzero value if the device is the primary display.

Currently, only the i386 is supported where the function checks for the
IORESOURCE_ROM_SHADOW flag.

Signed-off-by: Antonino Daplas <[email protected]>
Cc: David Miller <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
adaplas authored and Linus Torvalds committed Jul 17, 2007
1 parent 10eb265 commit 317b3c2
Show file tree
Hide file tree
Showing 27 changed files with 177 additions and 1 deletion.
1 change: 1 addition & 0 deletions arch/i386/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ drivers-$(CONFIG_PCI) += arch/i386/pci/
# must be linked after kernel/
drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/
drivers-$(CONFIG_PM) += arch/i386/power/
drivers-$(CONFIG_FB) += arch/i386/video/

CFLAGS += $(mflags-y)
AFLAGS += $(mflags-y)
Expand Down
1 change: 1 addition & 0 deletions arch/i386/video/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-$(CONFIG_FB) += fbdev.o
34 changes: 34 additions & 0 deletions arch/i386/video/fbdev.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* arch/i386/video/fbdev.c - i386 Framebuffer
*
* Copyright (C) 2007 Antonino Daplas <[email protected]>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*
*/
#include <linux/fb.h>
#include <linux/pci.h>

int fb_is_primary_device(struct fb_info *info)
{
struct device *device;
struct pci_dev *pci_dev = NULL;
struct resource *res = NULL;
int retval = 0;

device = info->device;

if (device)
pci_dev = to_pci_dev(device);

if (pci_dev)
res = &pci_dev->resource[PCI_ROM_RESOURCE];

if (res && res->flags & IORESOURCE_ROM_SHADOW)
retval = 1;

return retval;
}
EXPORT_SYMBOL(fb_is_primary_device);
6 changes: 6 additions & 0 deletions include/asm-alpha/fb.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/device.h>

/* Caching is off in the I/O space quadrant by design. */
#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-arm/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -10,4 +11,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-arm26/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-avr32/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -12,4 +13,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
| (_PAGE_BUFFER | _PAGE_DIRTY));
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-blackfin/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-cris/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-frv/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-h8300/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
3 changes: 3 additions & 0 deletions include/asm-i386/fb.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

extern int fb_is_primary_device(struct fb_info *info);

static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
{
Expand Down
6 changes: 6 additions & 0 deletions include/asm-ia64/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <linux/efi.h>
#include <asm/page.h>
Expand All @@ -14,4 +15,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-m32r/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -10,4 +11,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-m68k/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>
#include <asm/setup.h>
Expand All @@ -25,4 +26,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
}
#endif /* CONFIG_SUN3 */

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-m68knommu/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-mips/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -10,4 +11,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-parisc/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -10,4 +11,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-powerpc/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -12,4 +13,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-s390/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-sh/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -10,4 +11,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-sh64/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_

#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -10,4 +11,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-sparc/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-sparc64/fb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>
#include <linux/fs.h>
#include <asm/page.h>

Expand All @@ -9,4 +10,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
}

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
6 changes: 6 additions & 0 deletions include/asm-v850/fb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _ASM_FB_H_
#define _ASM_FB_H_
#include <linux/fb.h>

#define fb_pgprotect(...) do {} while (0)

static inline int fb_is_primary_device(struct fb_info *info)
{
return 0;
}

#endif /* _ASM_FB_H_ */
Loading

0 comments on commit 317b3c2

Please sign in to comment.