Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <adaplas@gmail.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Antonino A. Daplas and committed by
Linus Torvalds
317b3c21 10eb2659

+177 -1
+1
arch/i386/Makefile
··· 108 108 # must be linked after kernel/ 109 109 drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/ 110 110 drivers-$(CONFIG_PM) += arch/i386/power/ 111 + drivers-$(CONFIG_FB) += arch/i386/video/ 111 112 112 113 CFLAGS += $(mflags-y) 113 114 AFLAGS += $(mflags-y)
+1
arch/i386/video/Makefile
··· 1 + obj-$(CONFIG_FB) += fbdev.o
+34
arch/i386/video/fbdev.c
··· 1 + /* 2 + * arch/i386/video/fbdev.c - i386 Framebuffer 3 + * 4 + * Copyright (C) 2007 Antonino Daplas <adaplas@gmail.com> 5 + * 6 + * This file is subject to the terms and conditions of the GNU General Public 7 + * License. See the file COPYING in the main directory of this archive 8 + * for more details. 9 + * 10 + */ 11 + #include <linux/fb.h> 12 + #include <linux/pci.h> 13 + 14 + int fb_is_primary_device(struct fb_info *info) 15 + { 16 + struct device *device; 17 + struct pci_dev *pci_dev = NULL; 18 + struct resource *res = NULL; 19 + int retval = 0; 20 + 21 + device = info->device; 22 + 23 + if (device) 24 + pci_dev = to_pci_dev(device); 25 + 26 + if (pci_dev) 27 + res = &pci_dev->resource[PCI_ROM_RESOURCE]; 28 + 29 + if (res && res->flags & IORESOURCE_ROM_SHADOW) 30 + retval = 1; 31 + 32 + return retval; 33 + } 34 + EXPORT_SYMBOL(fb_is_primary_device);
+6
include/asm-alpha/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/device.h> 3 4 4 5 /* Caching is off in the I/O space quadrant by design. */ 5 6 #define fb_pgprotect(...) do {} while (0) 7 + 8 + static inline int fb_is_primary_device(struct fb_info *info) 9 + { 10 + return 0; 11 + } 6 12 7 13 #endif /* _ASM_FB_H_ */
+6
include/asm-arm/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 9 8 unsigned long off) 10 9 { 11 10 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 11 + } 12 + 13 + static inline int fb_is_primary_device(struct fb_info *info) 14 + { 15 + return 0; 12 16 } 13 17 14 18 #endif /* _ASM_FB_H_ */
+6
include/asm-arm26/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6
include/asm-avr32/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 11 10 vma->vm_page_prot = __pgprot((pgprot_val(vma->vm_page_prot) 12 11 & ~_PAGE_CACHABLE) 13 12 | (_PAGE_BUFFER | _PAGE_DIRTY)); 13 + } 14 + 15 + static inline int fb_is_primary_device(struct fb_info *info) 16 + { 17 + return 0; 14 18 } 15 19 16 20 #endif /* _ASM_FB_H_ */
+6
include/asm-blackfin/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6
include/asm-cris/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6
include/asm-frv/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6
include/asm-h8300/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+3
include/asm-i386/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 7 + 8 + extern int fb_is_primary_device(struct fb_info *info); 6 9 7 10 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, 8 11 unsigned long off)
+6
include/asm-ia64/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <linux/efi.h> 6 7 #include <asm/page.h> ··· 13 12 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 14 13 else 15 14 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 15 + } 16 + 17 + static inline int fb_is_primary_device(struct fb_info *info) 18 + { 19 + return 0; 16 20 } 17 21 18 22 #endif /* _ASM_FB_H_ */
+6
include/asm-m32r/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 9 8 unsigned long off) 10 9 { 11 10 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 11 + } 12 + 13 + static inline int fb_is_primary_device(struct fb_info *info) 14 + { 15 + return 0; 12 16 } 13 17 14 18 #endif /* _ASM_FB_H_ */
+6
include/asm-m68k/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 #include <asm/setup.h> ··· 25 24 } 26 25 } 27 26 #endif /* CONFIG_SUN3 */ 27 + 28 + static inline int fb_is_primary_device(struct fb_info *info) 29 + { 30 + return 0; 31 + } 28 32 29 33 #endif /* _ASM_FB_H_ */
+6
include/asm-m68knommu/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6
include/asm-mips/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 9 8 unsigned long off) 10 9 { 11 10 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 11 + } 12 + 13 + static inline int fb_is_primary_device(struct fb_info *info) 14 + { 15 + return 0; 12 16 } 13 17 14 18 #endif /* _ASM_FB_H_ */
+6
include/asm-parisc/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 9 8 unsigned long off) 10 9 { 11 10 pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; 11 + } 12 + 13 + static inline int fb_is_primary_device(struct fb_info *info) 14 + { 15 + return 0; 12 16 } 13 17 14 18 #endif /* _ASM_FB_H_ */
+6
include/asm-powerpc/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 11 10 vma->vm_page_prot = phys_mem_access_prot(file, off >> PAGE_SHIFT, 12 11 vma->vm_end - vma->vm_start, 13 12 vma->vm_page_prot); 13 + } 14 + 15 + static inline int fb_is_primary_device(struct fb_info *info) 16 + { 17 + return 0; 14 18 } 15 19 16 20 #endif /* _ASM_FB_H_ */
+6
include/asm-s390/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6
include/asm-sh/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 9 8 unsigned long off) 10 9 { 11 10 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 11 + } 12 + 13 + static inline int fb_is_primary_device(struct fb_info *info) 14 + { 15 + return 0; 12 16 } 13 17 14 18 #endif /* _ASM_FB_H_ */
+6
include/asm-sh64/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 3 4 + #include <linux/fb.h> 4 5 #include <linux/fs.h> 5 6 #include <asm/page.h> 6 7 ··· 9 8 unsigned long off) 10 9 { 11 10 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 11 + } 12 + 13 + static inline int fb_is_primary_device(struct fb_info *info) 14 + { 15 + return 0; 12 16 } 13 17 14 18 #endif /* _ASM_FB_H_ */
+6
include/asm-sparc/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6
include/asm-sparc64/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 #include <linux/fs.h> 4 5 #include <asm/page.h> 5 6 ··· 8 7 unsigned long off) 9 8 { 10 9 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 10 + } 11 + 12 + static inline int fb_is_primary_device(struct fb_info *info) 13 + { 14 + return 0; 11 15 } 12 16 13 17 #endif /* _ASM_FB_H_ */
+6
include/asm-v850/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */
+6 -1
include/asm-x86_64/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 - 3 + #include <linux/fb.h> 4 4 #include <linux/fs.h> 5 5 #include <asm/page.h> 6 6 ··· 9 9 { 10 10 if (boot_cpu_data.x86 > 3) 11 11 pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; 12 + } 13 + 14 + static inline int fb_is_primary_device(struct fb_info *info) 15 + { 16 + return 0; 12 17 } 13 18 14 19 #endif /* _ASM_FB_H_ */
+6
include/asm-xtensa/fb.h
··· 1 1 #ifndef _ASM_FB_H_ 2 2 #define _ASM_FB_H_ 3 + #include <linux/fb.h> 3 4 4 5 #define fb_pgprotect(...) do {} while (0) 6 + 7 + static inline int fb_is_primary_device(struct fb_info *info) 8 + { 9 + return 0; 10 + } 5 11 6 12 #endif /* _ASM_FB_H_ */