diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/gpu/drm/drm_modes.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/gpu/drm/drm_modes.c')
-rw-r--r-- | drivers/gpu/drm/drm_modes.c | 118 |
1 files changed, 31 insertions, 87 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 51f677215f1d..76d63394c776 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c | |||
@@ -1,9 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * The list_sort function is (presumably) licensed under the GPL (see the | ||
3 | * top level "COPYING" file for details). | ||
4 | * | ||
5 | * The remainder of this file is: | ||
6 | * | ||
7 | * Copyright © 1997-2003 by The XFree86 Project, Inc. | 2 | * Copyright © 1997-2003 by The XFree86 Project, Inc. |
8 | * Copyright © 2007 Dave Airlie | 3 | * Copyright © 2007 Dave Airlie |
9 | * Copyright © 2007-2008 Intel Corporation | 4 | * Copyright © 2007-2008 Intel Corporation |
@@ -36,6 +31,7 @@ | |||
36 | */ | 31 | */ |
37 | 32 | ||
38 | #include <linux/list.h> | 33 | #include <linux/list.h> |
34 | #include <linux/list_sort.h> | ||
39 | #include "drmP.h" | 35 | #include "drmP.h" |
40 | #include "drm.h" | 36 | #include "drm.h" |
41 | #include "drm_crtc.h" | 37 | #include "drm_crtc.h" |
@@ -553,6 +549,32 @@ int drm_mode_height(struct drm_display_mode *mode) | |||
553 | } | 549 | } |
554 | EXPORT_SYMBOL(drm_mode_height); | 550 | EXPORT_SYMBOL(drm_mode_height); |
555 | 551 | ||
552 | /** drm_mode_hsync - get the hsync of a mode | ||
553 | * @mode: mode | ||
554 | * | ||
555 | * LOCKING: | ||
556 | * None. | ||
557 | * | ||
558 | * Return @modes's hsync rate in kHz, rounded to the nearest int. | ||
559 | */ | ||
560 | int drm_mode_hsync(struct drm_display_mode *mode) | ||
561 | { | ||
562 | unsigned int calc_val; | ||
563 | |||
564 | if (mode->hsync) | ||
565 | return mode->hsync; | ||
566 | |||
567 | if (mode->htotal < 0) | ||
568 | return 0; | ||
569 | |||
570 | calc_val = (mode->clock * 1000) / mode->htotal; /* hsync in Hz */ | ||
571 | calc_val += 500; /* round to 1000Hz */ | ||
572 | calc_val /= 1000; /* truncate to kHz */ | ||
573 | |||
574 | return calc_val; | ||
575 | } | ||
576 | EXPORT_SYMBOL(drm_mode_hsync); | ||
577 | |||
556 | /** | 578 | /** |
557 | * drm_mode_vrefresh - get the vrefresh of a mode | 579 | * drm_mode_vrefresh - get the vrefresh of a mode |
558 | * @mode: mode | 580 | * @mode: mode |
@@ -560,7 +582,7 @@ EXPORT_SYMBOL(drm_mode_height); | |||
560 | * LOCKING: | 582 | * LOCKING: |
561 | * None. | 583 | * None. |
562 | * | 584 | * |
563 | * Return @mode's vrefresh rate or calculate it if necessary. | 585 | * Return @mode's vrefresh rate in Hz or calculate it if necessary. |
564 | * | 586 | * |
565 | * FIXME: why is this needed? shouldn't vrefresh be set already? | 587 | * FIXME: why is this needed? shouldn't vrefresh be set already? |
566 | * | 588 | * |
@@ -829,6 +851,7 @@ EXPORT_SYMBOL(drm_mode_prune_invalid); | |||
829 | 851 | ||
830 | /** | 852 | /** |
831 | * drm_mode_compare - compare modes for favorability | 853 | * drm_mode_compare - compare modes for favorability |
854 | * @priv: unused | ||
832 | * @lh_a: list_head for first mode | 855 | * @lh_a: list_head for first mode |
833 | * @lh_b: list_head for second mode | 856 | * @lh_b: list_head for second mode |
834 | * | 857 | * |
@@ -842,7 +865,7 @@ EXPORT_SYMBOL(drm_mode_prune_invalid); | |||
842 | * Negative if @lh_a is better than @lh_b, zero if they're equivalent, or | 865 | * Negative if @lh_a is better than @lh_b, zero if they're equivalent, or |
843 | * positive if @lh_b is better than @lh_a. | 866 | * positive if @lh_b is better than @lh_a. |
844 | */ | 867 | */ |
845 | static int drm_mode_compare(struct list_head *lh_a, struct list_head *lh_b) | 868 | static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head *lh_b) |
846 | { | 869 | { |
847 | struct drm_display_mode *a = list_entry(lh_a, struct drm_display_mode, head); | 870 | struct drm_display_mode *a = list_entry(lh_a, struct drm_display_mode, head); |
848 | struct drm_display_mode *b = list_entry(lh_b, struct drm_display_mode, head); | 871 | struct drm_display_mode *b = list_entry(lh_b, struct drm_display_mode, head); |
@@ -859,85 +882,6 @@ static int drm_mode_compare(struct list_head *lh_a, struct list_head *lh_b) | |||
859 | return diff; | 882 | return diff; |
860 | } | 883 | } |
861 | 884 | ||
862 | /* FIXME: what we don't have a list sort function? */ | ||
863 | /* list sort from Mark J Roberts (mjr@znex.org) */ | ||
864 | void list_sort(struct list_head *head, | ||
865 | int (*cmp)(struct list_head *a, struct list_head *b)) | ||
866 | { | ||
867 | struct list_head *p, *q, *e, *list, *tail, *oldhead; | ||
868 | int insize, nmerges, psize, qsize, i; | ||
869 | |||
870 | list = head->next; | ||
871 | list_del(head); | ||
872 | insize = 1; | ||
873 | for (;;) { | ||
874 | p = oldhead = list; | ||
875 | list = tail = NULL; | ||
876 | nmerges = 0; | ||
877 | |||
878 | while (p) { | ||
879 | nmerges++; | ||
880 | q = p; | ||
881 | psize = 0; | ||
882 | for (i = 0; i < insize; i++) { | ||
883 | psize++; | ||
884 | q = q->next == oldhead ? NULL : q->next; | ||
885 | if (!q) | ||
886 | break; | ||
887 | } | ||
888 | |||
889 | qsize = insize; | ||
890 | while (psize > 0 || (qsize > 0 && q)) { | ||
891 | if (!psize) { | ||
892 | e = q; | ||
893 | q = q->next; | ||
894 | qsize--; | ||
895 | if (q == oldhead) | ||
896 | q = NULL; | ||
897 | } else if (!qsize || !q) { | ||
898 | e = p; | ||
899 | p = p->next; | ||
900 | psize--; | ||
901 | if (p == oldhead) | ||
902 | p = NULL; | ||
903 | } else if (cmp(p, q) <= 0) { | ||
904 | e = p; | ||
905 | p = p->next; | ||
906 | psize--; | ||
907 | if (p == oldhead) | ||
908 | p = NULL; | ||
909 | } else { | ||
910 | e = q; | ||
911 | q = q->next; | ||
912 | qsize--; | ||
913 | if (q == oldhead) | ||
914 | q = NULL; | ||
915 | } | ||
916 | if (tail) | ||
917 | tail->next = e; | ||
918 | else | ||
919 | list = e; | ||
920 | e->prev = tail; | ||
921 | tail = e; | ||
922 | } | ||
923 | p = q; | ||
924 | } | ||
925 | |||
926 | tail->next = list; | ||
927 | list->prev = tail; | ||
928 | |||
929 | if (nmerges <= 1) | ||
930 | break; | ||
931 | |||
932 | insize *= 2; | ||
933 | } | ||
934 | |||
935 | head->next = list; | ||
936 | head->prev = list->prev; | ||
937 | list->prev->next = head; | ||
938 | list->prev = head; | ||
939 | } | ||
940 | |||
941 | /** | 885 | /** |
942 | * drm_mode_sort - sort mode list | 886 | * drm_mode_sort - sort mode list |
943 | * @mode_list: list to sort | 887 | * @mode_list: list to sort |
@@ -949,7 +893,7 @@ void list_sort(struct list_head *head, | |||
949 | */ | 893 | */ |
950 | void drm_mode_sort(struct list_head *mode_list) | 894 | void drm_mode_sort(struct list_head *mode_list) |
951 | { | 895 | { |
952 | list_sort(mode_list, drm_mode_compare); | 896 | list_sort(NULL, mode_list, drm_mode_compare); |
953 | } | 897 | } |
954 | EXPORT_SYMBOL(drm_mode_sort); | 898 | EXPORT_SYMBOL(drm_mode_sort); |
955 | 899 | ||