summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2020-07-11 22:46:00 +0100
committerAlastair Poole <netstar@gmail.com>2020-07-11 22:46:00 +0100
commite820efd81dc8604a8fa1806fbe24e636eb03cf0f (patch)
tree7c417d08a146ba43c3153383eeda208dc77818bd /src
parent1fa239b404ead097c1e019f6cdad6eb5f9f2f7e0 (diff)
cpufreq: FreeBSD et al.
Fix CPU frequency setting on FreeBSD/DragonFlyBSD. Also fix the display of the dial so it behaves identically to the Linux gadget.
Diffstat (limited to 'src')
-rw-r--r--src/modules/cpufreq/e_mod_main.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/modules/cpufreq/e_mod_main.c b/src/modules/cpufreq/e_mod_main.c
index 7cd79983f..677f360bf 100644
--- a/src/modules/cpufreq/e_mod_main.c
+++ b/src/modules/cpufreq/e_mod_main.c
@@ -62,7 +62,7 @@ static void _cpufreq_menu_frequency(void *data, E_Menu *m, E_Menu_Item *mi)
62static void _cpufreq_menu_pstate_min(void *data, E_Menu *m, E_Menu_Item *mi); 62static void _cpufreq_menu_pstate_min(void *data, E_Menu *m, E_Menu_Item *mi);
63static void _cpufreq_menu_pstate_max(void *data, E_Menu *m, E_Menu_Item *mi); 63static void _cpufreq_menu_pstate_max(void *data, E_Menu *m, E_Menu_Item *mi);
64 64
65#if defined(__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) 65#if defined (__OpenBSD__)
66#else 66#else
67static int _cpufreq_cb_sort(const void *item1, const void *item2); 67static int _cpufreq_cb_sort(const void *item1, const void *item2);
68#endif 68#endif
@@ -586,8 +586,8 @@ _cpufreq_set_frequency(int frequency)
586 return; 586 return;
587 } 587 }
588 588
589#ifndef __OpenBSD__ 589#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
590 /* OpenBSD doesn't have governors */ 590 /* No governors (yet). */
591 _cpufreq_set_governor("userspace"); 591 _cpufreq_set_governor("userspace");
592#endif 592#endif
593 _cpufreq_response_init(); 593 _cpufreq_response_init();
@@ -634,7 +634,7 @@ _cpufreq_status_free(Cpu_Status *s)
634 free(s); 634 free(s);
635} 635}
636 636
637#if defined(__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) 637#if defined (__OpenBSD__)
638#else 638#else
639static int 639static int
640_cpufreq_cb_sort(const void *item1, const void *item2) 640_cpufreq_cb_sort(const void *item1, const void *item2)
@@ -678,6 +678,8 @@ _cpufreq_status_check_available(Cpu_Status *s)
678 p = 25; 678 p = 25;
679 s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p); 679 s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p);
680#elif defined (__FreeBSD__) || defined(__DragonFly__) 680#elif defined (__FreeBSD__) || defined(__DragonFly__)
681 int freq_min = 0x7fffffff;
682 int freq_max = 0;
681 int freq; 683 int freq;
682 size_t len = sizeof(buf); 684 size_t len = sizeof(buf);
683 char *pos, *q; 685 char *pos, *q;
@@ -702,11 +704,20 @@ _cpufreq_status_check_available(Cpu_Status *s)
702 *q = '\0'; 704 *q = '\0';
703 freq = atoi(pos); 705 freq = atoi(pos);
704 freq *= 1000; 706 freq *= 1000;
707
708 if (freq > freq_max) freq_max = freq;
709 if (freq < freq_min) freq_min = freq;
710
705 s->frequencies = eina_list_append(s->frequencies, (void *)(long)freq); 711 s->frequencies = eina_list_append(s->frequencies, (void *)(long)freq);
706 712
707 pos = q + 1; 713 pos = q + 1;
708 pos = strchr(pos, ' '); 714 pos = strchr(pos, ' ');
709 } 715 }
716 s->cur_min_frequency = freq_min;
717 s->cur_max_frequency = freq_max;
718 s->frequencies = eina_list_sort(s->frequencies,
719 eina_list_count(s->frequencies),
720 _cpufreq_cb_sort);
710 } 721 }
711 722
712 /* sort is not necessary because freq_levels is already sorted */ 723 /* sort is not necessary because freq_levels is already sorted */
@@ -875,6 +886,8 @@ _cpufreq_status_check_current(Cpu_Status *s)
875 size_t len = sizeof(frequency); 886 size_t len = sizeof(frequency);
876 s->active = 0; 887 s->active = 0;
877 888
889 _cpufreq_status_check_available(s);
890
878 /* frequency is stored in dev.cpu.0.freq */ 891 /* frequency is stored in dev.cpu.0.freq */
879 if (sysctlbyname("dev.cpu.0.freq", &frequency, &len, NULL, 0) == 0) 892 if (sysctlbyname("dev.cpu.0.freq", &frequency, &len, NULL, 0) == 0)
880 { 893 {
@@ -887,7 +900,6 @@ _cpufreq_status_check_current(Cpu_Status *s)
887 /* hardcoded for testing */ 900 /* hardcoded for testing */
888 s->can_set_frequency = 1; 901 s->can_set_frequency = 1;
889 s->cur_governor = NULL; 902 s->cur_governor = NULL;
890
891#else 903#else
892 char buf[4096]; 904 char buf[4096];
893 FILE *f; 905 FILE *f;
@@ -1043,7 +1055,7 @@ _cpufreq_face_update_available(Instance *inst)
1043 edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_STRING_SET, 2, governor_msg); 1055 edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_STRING_SET, 2, governor_msg);
1044 free(governor_msg); 1056 free(governor_msg);
1045 } 1057 }
1046#if defined(__OpenBSD__) 1058#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
1047 _cpufreq_face_update_current(inst); 1059 _cpufreq_face_update_current(inst);
1048#endif 1060#endif
1049 1061