aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2007-05-08 03:38:25 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:28 -0400
commit36cc535b852bd59d04c43fe8e4c05c7da46bc625 (patch)
treec70f17456476a599d124a043029589eb500f51b4
parente296927bcc910ffa9e171c0108a4bf74c0836553 (diff)
skeletonfb: various corrections
This is mainly correction of types, typos and missing characters in the skeletonfb.c file found while trying to prepare a new fb driver. [adaplas] Additions on power management and fixes as per akpm Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Antonino Daplas <adaplas@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/video/skeletonfb.c195
1 files changed, 142 insertions, 53 deletions
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
index bb96cb65fdaa..9fda5b5d64dd 100644
--- a/drivers/video/skeletonfb.c
+++ b/drivers/video/skeletonfb.c
@@ -51,6 +51,7 @@
51#include <linux/delay.h> 51#include <linux/delay.h>
52#include <linux/fb.h> 52#include <linux/fb.h>
53#include <linux/init.h> 53#include <linux/init.h>
54#include <linux/pci.h>
54 55
55 /* 56 /*
56 * This is just simple sample code. 57 * This is just simple sample code.
@@ -60,6 +61,11 @@
60 */ 61 */
61 62
62/* 63/*
64 * Driver data
65 */
66static char *mode_option __devinitdata;
67
68/*
63 * If your driver supports multiple boards, you should make the 69 * If your driver supports multiple boards, you should make the
64 * below data types arrays, or allocate them dynamically (using kmalloc()). 70 * below data types arrays, or allocate them dynamically (using kmalloc()).
65 */ 71 */
@@ -278,7 +284,7 @@ static int xxxfb_set_par(struct fb_info *info)
278 */ 284 */
279static int xxxfb_setcolreg(unsigned regno, unsigned red, unsigned green, 285static int xxxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
280 unsigned blue, unsigned transp, 286 unsigned blue, unsigned transp,
281 const struct fb_info *info) 287 struct fb_info *info)
282{ 288{
283 if (regno >= 256) /* no. of hw registers */ 289 if (regno >= 256) /* no. of hw registers */
284 return -EINVAL; 290 return -EINVAL;
@@ -416,7 +422,7 @@ static int xxxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
416 * Returns negative errno on error, or zero on success. 422 * Returns negative errno on error, or zero on success.
417 */ 423 */
418static int xxxfb_pan_display(struct fb_var_screeninfo *var, 424static int xxxfb_pan_display(struct fb_var_screeninfo *var,
419 const struct fb_info *info) 425 struct fb_info *info)
420{ 426{
421 /* 427 /*
422 * If your hardware does not support panning, _do_ _not_ implement this 428 * If your hardware does not support panning, _do_ _not_ implement this
@@ -454,7 +460,7 @@ static int xxxfb_pan_display(struct fb_var_screeninfo *var,
454 * Return !0 for any modes that are unimplemented. 460 * Return !0 for any modes that are unimplemented.
455 * 461 *
456 */ 462 */
457static int xxxfb_blank(int blank_mode, const struct fb_info *info) 463static int xxxfb_blank(int blank_mode, struct fb_info *info)
458{ 464{
459 /* ... */ 465 /* ... */
460 return 0; 466 return 0;
@@ -483,7 +489,7 @@ static int xxxfb_blank(int blank_mode, const struct fb_info *info)
483 * depending on the rastering operation with the value of color which 489 * depending on the rastering operation with the value of color which
484 * is in the current color depth format. 490 * is in the current color depth format.
485 */ 491 */
486void xxfb_fillrect(struct fb_info *p, const struct fb_fillrect *region) 492void xxxfb_fillrect(struct fb_info *p, const struct fb_fillrect *region)
487{ 493{
488/* Meaning of struct fb_fillrect 494/* Meaning of struct fb_fillrect
489 * 495 *
@@ -647,21 +653,50 @@ void xxxfb_poll(struct fb_info *info, poll_table *wait)
647 * If the driver has implemented its own hardware-based drawing function, 653 * If the driver has implemented its own hardware-based drawing function,
648 * implementing this function is highly recommended. 654 * implementing this function is highly recommended.
649 */ 655 */
650void xxxfb_sync(struct fb_info *info) 656int xxxfb_sync(struct fb_info *info)
651{ 657{
658 return 0;
652} 659}
653 660
654 /* 661 /*
662 * Frame buffer operations
663 */
664
665static struct fb_ops xxxfb_ops = {
666 .owner = THIS_MODULE,
667 .fb_open = xxxfb_open,
668 .fb_read = xxxfb_read,
669 .fb_write = xxxfb_write,
670 .fb_release = xxxfb_release,
671 .fb_check_var = xxxfb_check_var,
672 .fb_set_par = xxxfb_set_par,
673 .fb_setcolreg = xxxfb_setcolreg,
674 .fb_blank = xxxfb_blank,
675 .fb_pan_display = xxxfb_pan_display,
676 .fb_fillrect = xxxfb_fillrect, /* Needed !!! */
677 .fb_copyarea = xxxfb_copyarea, /* Needed !!! */
678 .fb_imageblit = xxxfb_imageblit, /* Needed !!! */
679 .fb_cursor = xxxfb_cursor, /* Optional !!! */
680 .fb_rotate = xxxfb_rotate,
681 .fb_poll = xxxfb_poll,
682 .fb_sync = xxxfb_sync,
683 .fb_ioctl = xxxfb_ioctl,
684 .fb_mmap = xxxfb_mmap,
685};
686
687/* ------------------------------------------------------------------------- */
688
689 /*
655 * Initialization 690 * Initialization
656 */ 691 */
657 692
658/* static int __init xxfb_probe (struct device *device) -- for platform devs */ 693/* static int __init xxfb_probe (struct device *device) -- for platform devs */
659static int __init xxxfb_probe(struct pci_dev *dev, 694static int __devinit xxxfb_probe(struct pci_dev *dev,
660 const_struct pci_device_id *ent) 695 const_struct pci_device_id *ent)
661{ 696{
662 struct fb_info *info; 697 struct fb_info *info;
663 struct xxx_par *par; 698 struct xxx_par *par;
664 struct device = &dev->dev; /* for pci drivers */ 699 struct device* device = &dev->dev; /* for pci drivers */
665 int cmap_len, retval; 700 int cmap_len, retval;
666 701
667 /* 702 /*
@@ -760,7 +795,7 @@ static int __init xxxfb_probe(struct pci_dev *dev,
760 * 795 *
761 * NOTE: This field is currently unused. 796 * NOTE: This field is currently unused.
762 */ 797 */
763 info->pixmap.scan_align = 32 798 info->pixmap.scan_align = 32;
764/***************************** End optional stage ***************************/ 799/***************************** End optional stage ***************************/
765 800
766 /* 801 /*
@@ -770,13 +805,13 @@ static int __init xxxfb_probe(struct pci_dev *dev,
770 if (!mode_option) 805 if (!mode_option)
771 mode_option = "640x480@60"; 806 mode_option = "640x480@60";
772 807
773 retval = fb_find_mode(info->var, info, mode_option, NULL, 0, NULL, 8); 808 retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8);
774 809
775 if (!retval || retval == 4) 810 if (!retval || retval == 4)
776 return -EINVAL; 811 return -EINVAL;
777 812
778 /* This has to been done !!! */ 813 /* This has to been done !!! */
779 fb_alloc_cmap(info->cmap, cmap_len, 0); 814 fb_alloc_cmap(&info->cmap, cmap_len, 0);
780 815
781 /* 816 /*
782 * The following is done in the case of having hardware with a static 817 * The following is done in the case of having hardware with a static
@@ -811,15 +846,15 @@ static int __init xxxfb_probe(struct pci_dev *dev,
811 /* 846 /*
812 * Cleanup 847 * Cleanup
813 */ 848 */
814/* static void __exit xxxfb_remove(struct device *device) */ 849/* static void __devexit xxxfb_remove(struct device *device) */
815static void __exit xxxfb_remove(struct pci_dev *dev) 850static void __devexit xxxfb_remove(struct pci_dev *dev)
816{ 851{
817 struct fb_info *info = pci_get_drv_data(dev); 852 struct fb_info *info = pci_get_drvdata(dev);
818 /* or dev_get_drv_data(device); */ 853 /* or dev_get_drvdata(device); */
819 854
820 if (info) { 855 if (info) {
821 unregister_framebuffer(info); 856 unregister_framebuffer(info);
822 fb_dealloc_cmap(&info.cmap); 857 fb_dealloc_cmap(&info->cmap);
823 /* ... */ 858 /* ... */
824 framebuffer_release(info); 859 framebuffer_release(info);
825 } 860 }
@@ -827,18 +862,61 @@ static void __exit xxxfb_remove(struct pci_dev *dev)
827 return 0; 862 return 0;
828} 863}
829 864
830#if CONFIG_PCI 865#ifdef CONFIG_PCI
866#ifdef CONFIG_PM
867/**
868 * xxxfb_suspend - Optional but recommended function. Suspend the device.
869 * @dev: PCI device
870 * @msg: the suspend event code.
871 *
872 * See Documentation/power/devices.txt for more information
873 */
874static int xxxfb_suspend(struct pci_dev *dev, pm_message_t msg)
875{
876 struct fb_info *info = pci_get_drvdata(dev);
877 struct xxxfb_par *par = info->par;
878
879 /* suspend here */
880 return 0;
881}
882
883/**
884 * xxxfb_resume - Optional but recommended function. Resume the device.
885 * @dev: PCI device
886 *
887 * See Documentation/power/devices.txt for more information
888 */
889static int xxxfb_resume(struct pci_dev *dev)
890{
891 struct fb_info *info = pci_get_drvdata(dev);
892 struct xxxfb_par *par = info->par;
893
894 /* resume here */
895 return 0;
896}
897#else
898#define xxxfb_suspend NULL
899#define xxxfb_resume NULL
900#endif /* CONFIG_PM */
901
902static struct pci_device_id xxxfb_id_table[] = {
903 { PCI_VENDOR_ID_XXX, PCI_DEVICE_ID_XXX,
904 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
905 ADDR, 0 },
906 { 0, }
907};
908
831/* For PCI drivers */ 909/* For PCI drivers */
832static struct pci_driver xxxfb_driver = { 910static struct pci_driver xxxfb_driver = {
833 .name = "xxxfb", 911 .name = "xxxfb",
834 .id_table = xxxfb_devices, 912 .id_table = xxxfb_id_table,
835 .probe = xxxfb_probe, 913 .probe = xxxfb_probe,
836 .remove = __devexit_p(xxxfb_remove), 914 .remove = __devexit_p(xxxfb_remove),
837 .suspend = xxxfb_suspend, /* optional */ 915 .suspend = xxxfb_suspend, /* optional but recommended */
838 .resume = xxxfb_resume, /* optional */ 916 .resume = xxxfb_resume, /* optional but recommended */
839}; 917};
840 918
841static int __init xxxfb_init(void) 919int __init xxxfb_init(void)
842{ 920{
843 /* 921 /*
844 * For kernel boot options (in 'video=xxxfb:<options>' format) 922 * For kernel boot options (in 'video=xxxfb:<options>' format)
@@ -858,16 +936,53 @@ static void __exit xxxfb_exit(void)
858{ 936{
859 pci_unregister_driver(&xxxfb_driver); 937 pci_unregister_driver(&xxxfb_driver);
860} 938}
861#else 939#else /* non PCI, platform drivers */
862#include <linux/platform_device.h> 940#include <linux/platform_device.h>
863/* for platform devices */ 941/* for platform devices */
942
943#ifdef CONFIG_PM
944/**
945 * xxxfb_suspend - Optional but recommended function. Suspend the device.
946 * @dev: platform device
947 * @msg: the suspend event code.
948 *
949 * See Documentation/power/devices.txt for more information
950 */
951static int xxxfb_suspend(struct platform_device *dev, pm_message_t msg)
952{
953 struct fb_info *info = platform_get_drvdata(dev);
954 struct xxxfb_par *par = info->par;
955
956 /* suspend here */
957 return 0;
958}
959
960/**
961 * xxxfb_resume - Optional but recommended function. Resume the device.
962 * @dev: PCI device
963 *
964 * See Documentation/power/devices.txt for more information
965 */
966static int xxxfb_suspend(struct platform_dev *dev)
967{
968 struct fb_info *info = platform_get_drvdata(dev);
969 struct xxxfb_par *par = info->par;
970
971 /* resume here */
972 return 0;
973}
974#else
975#define xxxfb_suspend NULL
976#define xxxfb_resume NULL
977#endif /* CONFIG_PM */
978
864static struct device_driver xxxfb_driver = { 979static struct device_driver xxxfb_driver = {
865 .name = "xxxfb", 980 .name = "xxxfb",
866 .bus = &platform_bus_type, 981 .bus = &platform_bus_type,
867 .probe = xxxfb_probe, 982 .probe = xxxfb_probe,
868 .remove = xxxfb_remove, 983 .remove = xxxfb_remove,
869 .suspend = xxxfb_suspend, /* optional */ 984 .suspend = xxxfb_suspend, /* optional but recommended */
870 .resume = xxxfb_resume, /* optional */ 985 .resume = xxxfb_resume, /* optional but recommended */
871}; 986};
872 987
873static struct platform_device xxxfb_device = { 988static struct platform_device xxxfb_device = {
@@ -903,8 +1018,9 @@ static void __exit xxxfb_exit(void)
903 platform_device_unregister(&xxxfb_device); 1018 platform_device_unregister(&xxxfb_device);
904 driver_unregister(&xxxfb_driver); 1019 driver_unregister(&xxxfb_driver);
905} 1020}
906#endif 1021#endif /* CONFIG_PCI */
907 1022
1023#ifdef MODULE
908 /* 1024 /*
909 * Setup 1025 * Setup
910 */ 1026 */
@@ -917,34 +1033,7 @@ int __init xxxfb_setup(char *options)
917{ 1033{
918 /* Parse user speficied options (`video=xxxfb:') */ 1034 /* Parse user speficied options (`video=xxxfb:') */
919} 1035}
920 1036#endif /* MODULE *?
921/* ------------------------------------------------------------------------- */
922
923 /*
924 * Frame buffer operations
925 */
926
927static struct fb_ops xxxfb_ops = {
928 .owner = THIS_MODULE,
929 .fb_open = xxxfb_open,
930 .fb_read = xxxfb_read,
931 .fb_write = xxxfb_write,
932 .fb_release = xxxfb_release,
933 .fb_check_var = xxxfb_check_var,
934 .fb_set_par = xxxfb_set_par,
935 .fb_setcolreg = xxxfb_setcolreg,
936 .fb_blank = xxxfb_blank,
937 .fb_pan_display = xxxfb_pan_display,
938 .fb_fillrect = xxxfb_fillrect, /* Needed !!! */
939 .fb_copyarea = xxxfb_copyarea, /* Needed !!! */
940 .fb_imageblit = xxxfb_imageblit, /* Needed !!! */
941 .fb_cursor = xxxfb_cursor, /* Optional !!! */
942 .fb_rotate = xxxfb_rotate,
943 .fb_poll = xxxfb_poll,
944 .fb_sync = xxxfb_sync,
945 .fb_ioctl = xxxfb_ioctl,
946 .fb_mmap = xxxfb_mmap,
947};
948 1037
949/* ------------------------------------------------------------------------- */ 1038/* ------------------------------------------------------------------------- */
950 1039
@@ -954,6 +1043,6 @@ static struct fb_ops xxxfb_ops = {
954 */ 1043 */
955 1044
956module_init(xxxfb_init); 1045module_init(xxxfb_init);
957module_exit(xxxfb_cleanup); 1046module_exit(xxxfb_remove);
958 1047
959MODULE_LICENSE("GPL"); 1048MODULE_LICENSE("GPL");