From: Antonino A. Daplas Date: Tue, 17 Jul 2007 11:05:28 +0000 (-0700) Subject: fbdev: detect primary display device X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=317b3c2167f5326a7de30a1abe50c9897da7a0e3;p=openwrt%2Fstaging%2Fblogic.git fbdev: detect primary display device 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 Cc: David Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/i386/Makefile b/arch/i386/Makefile index bd28f9f9b4b7..181cc29a7c4f 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -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) diff --git a/arch/i386/video/Makefile b/arch/i386/video/Makefile new file mode 100644 index 000000000000..2c447c94adcc --- /dev/null +++ b/arch/i386/video/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_FB) += fbdev.o diff --git a/arch/i386/video/fbdev.c b/arch/i386/video/fbdev.c new file mode 100644 index 000000000000..7fc712c46a64 --- /dev/null +++ b/arch/i386/video/fbdev.c @@ -0,0 +1,34 @@ +/* + * arch/i386/video/fbdev.c - i386 Framebuffer + * + * Copyright (C) 2007 Antonino Daplas + * + * 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 +#include + +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); diff --git a/include/asm-alpha/fb.h b/include/asm-alpha/fb.h index ca714a4e3557..fa9bbb96b2b3 100644 --- a/include/asm-alpha/fb.h +++ b/include/asm-alpha/fb.h @@ -1,7 +1,13 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include /* 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_ */ diff --git a/include/asm-arm/fb.h b/include/asm-arm/fb.h index 4bf5b88d90bf..d92e99cd8c8a 100644 --- a/include/asm-arm/fb.h +++ b/include/asm-arm/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-arm26/fb.h b/include/asm-arm26/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-arm26/fb.h +++ b/include/asm-arm26/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-avr32/fb.h b/include/asm-avr32/fb.h index d22a4a876694..41baf84ad402 100644 --- a/include/asm-avr32/fb.h +++ b/include/asm-avr32/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-blackfin/fb.h b/include/asm-blackfin/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-blackfin/fb.h +++ b/include/asm-blackfin/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-cris/fb.h b/include/asm-cris/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-cris/fb.h +++ b/include/asm-cris/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-frv/fb.h b/include/asm-frv/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-frv/fb.h +++ b/include/asm-frv/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-h8300/fb.h b/include/asm-h8300/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-h8300/fb.h +++ b/include/asm-h8300/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-i386/fb.h b/include/asm-i386/fb.h index d30073c75586..d1c6297d4a61 100644 --- a/include/asm-i386/fb.h +++ b/include/asm-i386/fb.h @@ -1,9 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include +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) { diff --git a/include/asm-ia64/fb.h b/include/asm-ia64/fb.h index 9d4577f9fe0e..89a397cee90a 100644 --- a/include/asm-ia64/fb.h +++ b/include/asm-ia64/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include #include @@ -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_ */ diff --git a/include/asm-m32r/fb.h b/include/asm-m32r/fb.h index 4bf5b88d90bf..d92e99cd8c8a 100644 --- a/include/asm-m32r/fb.h +++ b/include/asm-m32r/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-m68k/fb.h b/include/asm-m68k/fb.h index f78bad476b08..380b97ae8157 100644 --- a/include/asm-m68k/fb.h +++ b/include/asm-m68k/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include #include @@ -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_ */ diff --git a/include/asm-m68knommu/fb.h b/include/asm-m68knommu/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-m68knommu/fb.h +++ b/include/asm-m68knommu/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-mips/fb.h b/include/asm-mips/fb.h index ac23d96e261a..bd3f68c9ddfc 100644 --- a/include/asm-mips/fb.h +++ b/include/asm-mips/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-parisc/fb.h b/include/asm-parisc/fb.h index d5e47edf5321..4d503a023ab2 100644 --- a/include/asm-parisc/fb.h +++ b/include/asm-parisc/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-powerpc/fb.h b/include/asm-powerpc/fb.h index e13d6ebc116d..411af8d17a69 100644 --- a/include/asm-powerpc/fb.h +++ b/include/asm-powerpc/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-s390/fb.h b/include/asm-s390/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-s390/fb.h +++ b/include/asm-s390/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-sh/fb.h b/include/asm-sh/fb.h index 4bf5b88d90bf..d92e99cd8c8a 100644 --- a/include/asm-sh/fb.h +++ b/include/asm-sh/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-sh64/fb.h b/include/asm-sh64/fb.h index 4bf5b88d90bf..d92e99cd8c8a 100644 --- a/include/asm-sh64/fb.h +++ b/include/asm-sh64/fb.h @@ -1,6 +1,7 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-sparc/fb.h b/include/asm-sparc/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-sparc/fb.h +++ b/include/asm-sparc/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-sparc64/fb.h b/include/asm-sparc64/fb.h index 8703c707e142..d6cd3a175fc3 100644 --- a/include/asm-sparc64/fb.h +++ b/include/asm-sparc64/fb.h @@ -1,5 +1,6 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #include #include @@ -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_ */ diff --git a/include/asm-v850/fb.h b/include/asm-v850/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-v850/fb.h +++ b/include/asm-v850/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-x86_64/fb.h b/include/asm-x86_64/fb.h index d30073c75586..60548e651d12 100644 --- a/include/asm-x86_64/fb.h +++ b/include/asm-x86_64/fb.h @@ -1,6 +1,6 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ - +#include #include #include @@ -11,4 +11,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; } +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */ diff --git a/include/asm-xtensa/fb.h b/include/asm-xtensa/fb.h index 9f8c88d05df4..c7df38030992 100644 --- a/include/asm-xtensa/fb.h +++ b/include/asm-xtensa/fb.h @@ -1,6 +1,12 @@ #ifndef _ASM_FB_H_ #define _ASM_FB_H_ +#include #define fb_pgprotect(...) do {} while (0) +static inline int fb_is_primary_device(struct fb_info *info) +{ + return 0; +} + #endif /* _ASM_FB_H_ */