-default_CONFIG = CONFIG_DEMO_CAMERA=n CONFIG_DEMO_DCAMERA=y
+default_CONFIG = CONFIG_DEMO_VIDEO=y CONFIG_DEMO_CAMERA=n CONFIG_DEMO_DCAMERA=y
SUBDIRS=$(SUBDIRS-y)
+SUBDIRS-$(CONFIG_DEMO_VIDEO) += video
SUBDIRS-$(CONFIG_DEMO_CAMERA) += camera
SUBDIRS-$(CONFIG_DEMO_DCAMERA) += dcamera
+
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+FRSH_LIBS = frsh
+lib_LOADLIBES+= m pthread rt $(FRSH_LIBS)
+
+bin_PROGRAMS = fplayer
+fplayer_SOURCES = play.c play.h
+
+bin_PROGRAMS += fplayer_th
+fplayer_th_SOURCES = play_th.c play_th.h
+
--- /dev/null
+#include "play.h"
+
+frsh_rel_time_t player_budget, player_period;
+frsh_contract_t player_contract;
+frsh_thread_id_t player_thread;
+frsh_vres_id_t player_vres;
+
+sem_t *player_stopper;
+int stopper_fd;
+
+void player(struct player_args *args)
+{
+ char cmd[255];
+
+ fprintf(stdout, "== Waiting for being bound...\n");
+
+ sem_wait(player_stopper);
+ munmap(player_stopper, sizeof(sem_t));
+
+ fprintf(stdout,
+ "== Starting playing %s, with %d/%d CPU bandwidth\n",
+ args->file, args->budget, args->period);
+
+ snprintf(cmd, 255, PLAYER_BINARY PLAYER_ARGS " %s", args->file);
+ fprintf(stdout, "== Issuing command:\n %s\n", cmd);
+
+ execlp(PLAYER_BINARY, PLAYER_BINARY, PLAYER_ARGS, args->file, (char*) NULL);
+}
+
+int main(int argc, char *argv[])
+{
+ struct player_args args;
+ int player_status;
+ pid_t player_pid;
+ int opt, terror;
+
+ if (argc < 7) {
+err_usage:
+ fprintf(stderr, "USAGE:\n"
+ "%s -b budget_usec -p period_usec -f file\n\n",
+ argv[0]);
+ error(EXIT_FAILURE, EINVAL, "Wrong argument count");
+ }
+
+ while ((opt = getopt(argc, argv, "b:p:f:")) != -1) {
+ switch (opt) {
+ case 'b':
+ args.budget = atoi(optarg);
+ break;
+ case 'p':
+ args.period = atoi(optarg);
+ break;
+ case 'f':
+ strncpy(args.file, optarg, sizeof(args.file));
+ break;
+ default:
+ goto err_usage;
+ }
+ }
+
+ PXW(frsh_init());
+
+ stopper_fd = shm_open("/stopper", O_CREAT|O_EXCL|O_RDWR, S_IRWXU);
+ if (stopper_fd < 0) assert_perror(errno);
+
+ terror = ftruncate(stopper_fd, sizeof(sem_t));
+ if (terror) {
+ shm_unlink("/stopper");
+ assert_perror(errno);
+ }
+
+ player_stopper = mmap(NULL, sizeof(sem_t), PROT_READ|PROT_WRITE,
+ MAP_SHARED, stopper_fd, 0);
+ if (player_stopper == MAP_FAILED) {
+ shm_unlink("/stopper");
+ assert_perror(errno);
+ }
+
+ terror = close(stopper_fd);
+ if (terror) {
+ shm_unlink("/stopper");
+ assert_perror(errno);
+ }
+
+ sem_init(player_stopper, 1, 0);
+ fprintf(stderr, "FRSH initialized\n");
+
+ player_budget = fosa_usec_to_rel_time(args.budget);
+ player_period = fosa_usec_to_rel_time(args.period);
+ PXW(frsh_contract_init(&player_contract));
+ PXW(frsh_contract_set_basic_params(&player_contract,
+ &player_budget,
+ &player_period,
+ FRSH_WT_INDETERMINATE,
+ FRSH_CT_REGULAR));
+ PXW(frsh_contract_set_resource_and_label(&player_contract,
+ FRSH_RT_PROCESSOR,
+ 0,
+ "PLAYER_CONTRACT"));
+ fprintf(stdout, "Player contract initialized\n");
+
+ PXW(frsh_contract_negotiate(&player_contract, &player_vres));
+ fprintf(stdout, "Player contract negotiated\n");
+
+ terror = player_pid = fork();
+ if (terror < 0) {
+ /* error */
+ assert_perror(errno);
+ } else if (!terror) {
+ /* child process: */
+ player(&args);
+ }
+
+ player_thread.linux_pid = player_thread.linux_tid = player_pid;
+ PXW(frsh_thread_bind(player_vres, player_thread));
+ fprintf(stdout, "Player thread bound to its contract\n");
+
+ sem_post(player_stopper);
+ munmap(player_stopper, sizeof(sem_t));
+ shm_unlink("/stopper");
+
+ waitpid(player_pid, &player_status, 0);
+ if (WIFEXITED(player_status))
+ fprintf(stdout, "Playback finished normally\n");
+ else if (WIFSIGNALED(player_status))
+ fprintf(stdout, "Playback aborted\n");
+
+ PXW(frsh_contract_cancel(player_vres));
+
+ exit(EXIT_SUCCESS);
+}
+
--- /dev/null
+#ifndef _PLAY_H_
+#define _PLAY_H_
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <error.h>
+#include <assert.h>
+#include <semaphore.h>
+#include <sys/wait.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#include <frsh.h>
+
+#define PLAYER_BINARY "mplayer"
+#define PLAYER_ARGS " -fs -zoom "
+
+struct player_args {
+ int budget, period;
+ char file[128];
+};
+
+void player(struct player_args *args);
+
+#endif /* _PLAY_H_ */
+
--- /dev/null
+#include "play_th.h"
+
+static void player_cleanup(void *arg)
+{
+ frsh_vres_id_t vres;
+
+ frsh_thread_get_vres_id(fosa_thread_self(), &vres);
+ frsh_contract_cancel(vres);
+}
+
+void *player(void *thread_args)
+{
+ struct player_args *args = (struct player_args*) thread_args;
+
+ frsh_rel_time_t player_budget, player_period;
+ frsh_contract_t player_contract;
+ frsh_vres_id_t player_vres;
+
+ int terror, status;
+ char cmd[255];
+
+ fprintf(stdout, "== Waiting for being bound...\n");
+
+ fprintf(stdout,
+ "== Starting playing %s, with %d/%d CPU bandwidth\n",
+ args->file, args->budget, args->period);
+
+ player_budget = fosa_usec_to_rel_time(args->budget);
+ player_period = fosa_usec_to_rel_time(args->period);
+ PXW(frsh_contract_init(&player_contract));
+ PXW(frsh_contract_set_basic_params(&player_contract,
+ &player_budget,
+ &player_period,
+ FRSH_WT_INDETERMINATE,
+ FRSH_CT_REGULAR));
+ PXW(frsh_contract_set_resource_and_label(&player_contract,
+ FRSH_RT_PROCESSOR,
+ 0,
+ "PLAYER_CONTRACT"));
+ fprintf(stdout, "== Player contract initialized\n");
+
+ PXW(frsh_contract_negotiate(&player_contract, &player_vres));
+ fprintf(stdout, "== Player contract negotiated\n");
+
+ pthread_cleanup_push(player_cleanup, NULL);
+
+ PXW(frsh_thread_bind(player_vres, fosa_thread_self()));
+ fprintf(stdout, "== Player thread bound to its contract\n");
+
+ snprintf(cmd, 255, PLAYER_BINARY PLAYER_ARGS " %s", args->file);
+
+ fprintf(stdout, "== Issuing command:\n %s\n", cmd);
+
+ status = system(cmd);
+
+ if (WIFEXITED(status))
+ fprintf(stdout, "== Playback finished normally\n");
+ else if (WIFSIGNALED(status))
+ fprintf(stdout, "== Playback aborted\n");
+
+ pthread_cleanup_pop(1);
+
+ pthread_exit(EXIT_SUCCESS);
+}
+
+int main(int argc, char *argv[])
+{
+ pthread_t player_thread;
+ pthread_attr_t player_attr;
+ struct player_args args;
+ int opt, terror;
+
+ if (argc < 7) {
+err_usage:
+ fprintf(stderr, "USAGE:\n"
+ "%s -b budget_usec -p period_usec -f file\n\n",
+ argv[0]);
+ error(EXIT_FAILURE, EINVAL, "Wrong argument count");
+ }
+
+ while ((opt = getopt(argc, argv, "b:p:f:")) != -1) {
+ switch (opt) {
+ case 'b':
+ args.budget = atoi(optarg);
+ break;
+ case 'p':
+ args.period = atoi(optarg);
+ break;
+ case 'f':
+ strncpy(args.file, optarg, sizeof(args.file));
+ break;
+ default:
+ goto err_usage;
+ }
+ }
+
+ PXW(frsh_init());
+ fprintf(stdout, "FRSH initialized\n");
+
+ terror = pthread_attr_init(&player_attr);
+ if (terror) assert_perror(errno);
+
+ terror = pthread_create(&player_thread, &player_attr, player, (void*) &args);
+ if (terror) assert_perror(errno);
+ fprintf(stdout, "FRSH thread created, waiting for its termination...\n");
+
+ terror = pthread_join(player_thread, NULL);
+ if (terror) assert_perror(errno);
+ fprintf(stdout, "FRSH thread ended. Exiting\n\n");
+
+ exit(EXIT_SUCCESS);
+}
+
--- /dev/null
+#ifndef _PLAY_H_
+#define _PLAY_H_
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <error.h>
+#include <assert.h>
+#include <semaphore.h>
+#include <sys/wait.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#include <frsh.h>
+
+#define PLAYER_BINARY "mplayer"
+#define PLAYER_ARGS " -fs -zoom "
+
+struct player_args {
+ int budget, period;
+ char file[128];
+};
+
+void *player(void *args);
+
+#endif /* _PLAY_H_ */
+
ret = frsh_battery_get_expiration(&exp_time);
if (ret) goto err;
- if (fosa_abs_time_smaller(req_time, exp_time))
+ if (fosa_abs_time_smaller(exp_time, req_time))
ret = FRSH_ERR_CONTRACT_REJECTED;
}
case FRSH_RT_PROCESSOR:
{
int ret;
+
ret = fra_CPU_power_init(resource_id);
if (ret) return FRSH_ERR_INTERNAL_ERROR;
ret = fra_CPU_set_power(resource_id, power_level);
case FRSH_RT_LCD:
{
int ret;
+
ret = fra_LCD_power_init(resource_id);
if (ret) return FRSH_ERR_INTERNAL_ERROR;
ret = fra_LCD_set_power(resource_id, power_level);
case FRSH_RT_PROCESSOR:
{
int ret;
+
+ ret = fra_CPU_power_init(resource_id);
+ if (ret) return FRSH_ERR_INTERNAL_ERROR;
ret = fra_CPU_get_power(resource_id,
(int*) power_level);
if (ret) return FRSH_ERR_INTERNAL_ERROR;
case FRSH_RT_LCD:
{
int ret;
+
+ ret = fra_LCD_power_init(resource_id);
+ if (ret) return FRSH_ERR_INTERNAL_ERROR;
ret = fra_LCD_get_power(resource_id,
(int*) power_level);
if (ret) return FRSH_ERR_INTERNAL_ERROR;
return FRSH_NO_ERROR;
}
+int frsh_resource_get_speed
+ (frsh_resource_type_t resource_type,
+ frsh_resource_id_t resource_id,
+ frsh_power_level_t power_level,
+ double *speed_ratio)
+{
+ switch(resource_type)
+ {
+#ifdef CONFIG_ACPI_CPU
+ case FRSH_RT_PROCESSOR:
+ {
+ int ret;
+
+ ret = fra_CPU_power_init(resource_id);
+ if (ret) return FRSH_ERR_INTERNAL_ERROR;
+ ret = fra_CPU_get_speed(resource_id,
+ (int) power_level,
+ speed_ratio);
+ if (ret) return FRSH_ERR_INTERNAL_ERROR;
+
+ break;
+ }
+#endif
+#ifdef CONFIG_ACPI_LCD
+ case FRSH_RT_LCD:
+ {
+ int ret;
+
+ ret = fra_LCD_power_init(resource_id);
+ if (ret) return FRSH_ERR_INTERNAL_ERROR;
+ ret = fra_LCD_get_speed(resource_id,
+ (int) power_level,
+ speed_ratio);
+ if (ret) return FRSH_ERR_INTERNAL_ERROR;
+
+ break;
+ }
+#endif
+ default:
+ return FRSH_ERR_NOT_IMPLEMENTED;
+ }
+
+ return FRSH_NO_ERROR;
+}
+
int frsh_resource_get_num_power_levels
(frsh_resource_type_t resource_type,
frsh_resource_id_t resource_id,
if (ret) return FRSH_ERR_INTERNAL_ERROR;
ret = fra_battery_expiration(&interval);
- if (ret == EAGAIN) {
- *expiration = fosa_msec_to_abs_time(0);
- goto out;
- }
- if (ret)
- return FRSH_ERR_INTERNAL_ERROR;
+ if (ret == EAGAIN) return ret;
+ if (ret) return FRSH_ERR_INTERNAL_ERROR;
fosa_clock_get_time(FOSA_CLOCK_REALTIME, expiration);
*expiration = fosa_abs_time_incr(*expiration, interval);
-out:
return FRSH_NO_ERROR;
#else
return FRSH_ERR_NOT_IMPLEMENTED;
#include <frsh.h>
-#include <aqcpu_res.h>
-#include <error.h>
int main()
{
- int ret;
+ int terror;
frsh_vres_id_t vres;
frsh_contract_t contract;
frsh_rel_time_t budget, period;
- frsh_rel_time_t duration, expiration;
- unsigned long long duration_msec = 10000;
+ frsh_rel_time_t current, duration, expiration;
+ unsigned long duration_msec, duration_step;
- if (frsh_init())
- error(1, 0, "FRSH initialization failed\n");
+ PXW(frsh_init());
+
+ PXW(frsh_contract_init(&contract));
+
+ duration_msec = duration_step = 1000UL * 60UL * 10UL;
- /* Contract negotiation for CPU */
- ret = frsh_contract_init(&contract);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_init");
-
budget = fosa_msec_to_rel_time(10);
period = fosa_msec_to_rel_time(100);
- ret = frsh_contract_set_basic_params(&contract,
- &budget,
- &period,
- FRSH_WT_BOUNDED,
- FRSH_CT_REGULAR);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params");
+ PXW(frsh_contract_set_basic_params(&contract,
+ &budget,
+ &period,
+ FRSH_WT_BOUNDED,
+ FRSH_CT_REGULAR));
+
+ PXW(frsh_contract_set_resource_and_label(&contract, FRSH_RT_PROCESSOR, 0,"TEST_VRES"));
+
+ PXW(frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_HIGH, &budget));
- ret = frsh_contract_set_resource_and_label(&contract, FRSH_RT_PROCESSOR,
- 0,"TEST_VRES");
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label");
+ PXW(frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_MEDIUM, &budget));
- ret = frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_HIGH, &budget);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_min_budget_pow (FRSH_PLT_HIGH)");
+ PXW(frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_LOW, &budget));
- ret = frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_MEDIUM, &budget);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_min_budget_pow (FRSH_PLT_MEDIUM)");
+ terror = frsh_battery_get_expiration(&expiration);
+ if (terror == EAGAIN)
+ PERROR_AND_EXIT(terror, "frsh_battery_get_expiration: system running on AC");
+ if (terror)
+ PERROR_AND_EXIT(terror, "frsh_battery_get_expiration");
- ret = frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_LOW, &budget);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_min_budget_pow (FRSH_PLT_LOW)");
+ fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t);
+ printf("System battery wil expire in %lu seconds\n",
+ fosa_rel_time_to_msec(fosa_abs_time_decr(expiration, current)) / 1000UL);
+
+ printf("Starting with minumum diration = %lu seconds\n"
+ " ans stepping by %lu seconds.\n",
+ duration_msec / 1000UL,
+ duration_step / 1000UL);
duration = fosa_msec_to_rel_time(duration_msec);
- ret = frsh_contract_set_min_expiration(&contract, duration);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_min_expiration");
+ PXW(frsh_contract_set_min_expiration(&contract, duration));
- ret = frsh_contract_get_min_expiration(&contract, &duration);
- if (ret || fosa_rel_time_to_msec(duration) != duration_msec)
- PERROR_AND_EXIT(ret, "frsh_contract_get_min_expiration");
- printf("Minimum duration correctly set to: %lu\n", fosa_rel_time_to_msec(duration));
+ PXW(frsh_contract_get_min_expiration(&contract, &duration));
- ret = frsh_contract_negotiate(&contract, &vres);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
+ PXW(frsh_contract_negotiate(&contract, &vres));
printf("Aqcpu vres negotiated, vres-ID: %d\n", (int) vres);
while (1) {
- duration_msec += duration_msec;
+ duration_msec += duration_step;
duration = fosa_msec_to_rel_time(duration_msec);
- ret = frsh_contract_set_min_expiration(&contract, duration);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_min_expiration");
-
- ret = frsh_contract_get_min_expiration(&contract, &duration);
- if (ret || fosa_rel_time_to_msec(duration) != duration_msec) {
- //PERROR_AND_EXIT(ret, "frsh_contract_get_duration");
- printf("%lu %lu\n", fosa_rel_time_to_msec(duration), duration_msec);
- break;
- }
- printf("Minimum duration correctly set to: %lu\n",
- fosa_rel_time_to_msec(duration));
+ fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t);
+ printf(" Renegotiating the contract with minimum expiration %lu sec.\n"
+ " System expiration time: %lu seconds\n",
+ fosa_rel_time_to_msec(duration) / 1000UL,
+ fosa_rel_time_to_msec(fosa_abs_time_decr(expiration, current)) / 1000UL);
- ret = frsh_battery_get_expiration(&expiration);
- if (ret) PERROR_AND_EXIT(ret, "frsh_battery_get_expiration");
+ PXW(frsh_contract_set_min_expiration(&contract, duration));
- ret = frsh_contract_renegotiate_sync(&contract, vres);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_renegotiate_sync");
-
- printf("Contract with minimum expiration %lu renegotiated."
- "System expiration time: %lu\n",
- fosa_rel_time_to_msec(duration),
- fosa_abs_time_to_msec(expiration));
+ PXW(frsh_battery_get_expiration(&expiration));
+ terror = frsh_contract_renegotiate_sync(&contract, vres);
+ if (terror == FRSH_ERR_CONTRACT_REJECTED) {
+ PERROR_FRESCOR(terror, "frsh_contract_renegotiate_sync");
+ goto out;
+ }
+ if (terror) PERROR_AND_EXIT(terror, "frsh_contract_renegotiate_sync");
sleep(3);
}
- ret = frsh_contract_cancel(vres);
- if (ret) PERROR_AND_EXIT(ret, "frsh_contract_cancel");
+out:
+ PXW(frsh_contract_cancel(vres));
printf("Test PASSED!\n");
int fra_CPU_set_power(int cpu, int level)
{
- if (!frequency_initialized ||
- level >= 3)
+ if (!frequency_initialized || level >= 3)
return EINVAL;
return cpufreq_set_frequency(cpu, freqs[level]);
}
+int fra_CPU_get_speed(int cpu, int level, double *ratio)
+{
+ if (!frequency_initialized || level >= 3)
+ return EINVAL;
+
+ *ratio = (double) freqs[level] / freqs[0];
+
+ return 0;
+}
+
int fra_CPU_set_power(int cpu, int level);
+int fra_CPU_get_speed(int cpu, int level, double *ratio);
+
#endif
#include <frsh.h>
-#include <error.h>
int main()
{
+ frsh_power_level_t level;
int power_levels;
- int ret;
+ double speed;
+ int terror;
- if (frsh_init())
- error(1, 0, "FRSH initialization failed\n");
+ PXW(frsh_init());
- ret = frsh_resource_get_num_power_levels(FRSH_RT_PROCESSOR,
- 0, &power_levels);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_get_num_power_levels");
+ PXW(frsh_resource_get_num_power_levels(FRSH_RT_PROCESSOR, 0, &power_levels));
printf("Number of power levels suppoerted: %d\n", power_levels);
if (power_levels == 1)
PERROR_AND_EXIT(EINVAL, "Different power levels not supported");
-
- printf("Starting...\n");
+
+ PXW(frsh_resource_get_power_level(FRSH_RT_PROCESSOR, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_PROCESSOR, 0, level, &speed));
+ printf("Starting with power level %d, speed = %f\n", level, speed);
sleep(3);
- ret = frsh_resource_set_power_level(FRSH_RT_PROCESSOR,
- 0, FRSH_PLT_HIGH);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_set_power_level");
- printf("FRSH_PLT_MEDIUM correctly set\n");
+ PXW(frsh_resource_set_power_level(FRSH_RT_PROCESSOR, 0, FRSH_PLT_HIGH));
+ PXW(frsh_resource_get_power_level(FRSH_RT_PROCESSOR, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_PROCESSOR, 0, level, &speed));
+ printf("%d (FRSH_PLT_HIGH) correctly set, speed = %f\n", level, speed);
sleep(3);
- ret = frsh_resource_set_power_level(FRSH_RT_PROCESSOR,
- 0, FRSH_PLT_MEDIUM);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_set_power_level");
- printf("FRSH_PLT_MEDIUM correctly set\n");
+ PXW(frsh_resource_set_power_level(FRSH_RT_PROCESSOR, 0, FRSH_PLT_MEDIUM));
+ PXW(frsh_resource_get_power_level(FRSH_RT_PROCESSOR, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_PROCESSOR, 0, level, &speed));
+ printf("%d (FRSH_PLT_MEDIUM) correctly set, speed = %f\n", level, speed);
sleep(3);
- ret = frsh_resource_set_power_level(FRSH_RT_PROCESSOR,
- 0, FRSH_PLT_LOW);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_set_power_level");
- printf("FRSH_PLT_LOW correctly set\n");
+ PXW(frsh_resource_set_power_level(FRSH_RT_PROCESSOR, 0, FRSH_PLT_LOW));
+ PXW(frsh_resource_get_power_level(FRSH_RT_PROCESSOR, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_PROCESSOR, 0, level, &speed));
+ printf("%d (FRSH_PLT_LOW) correctly set, speed = %f\n", level, speed);
- return 0;
+ return 0;
}
int ret = 0;
char str[128];
- if (lcd_initialized == NONE)
+ if (lcd_initialized == NONE || level >= 3)
return EINVAL;
if (lcd_initialized == PROC_1) {
return __set_lcd_brightness(level);
}
+int fra_LCD_get_speed(int lcd, int level, double *ratio)
+{
+ if (lcd_initialized == NONE || level >= 3)
+ return EINVAL;
+
+ *ratio = bright[level]/bright[0];
+
+ return 0;
+}
+
int fra_LCD_set_power(int lcd, int level);
+int fra_LCD_get_speed(int lcd, int level, double *ratio);
+
#endif
#include <frsh.h>
-#include <error.h>
int main()
{
+ frsh_power_level_t level;
int power_levels;
- int ret;
+ double speed;
+ int terror;
- if (frsh_init())
- error(1, 0, "FRSH initialization failed\n");
+ PXW(frsh_init());
- ret = frsh_resource_get_num_power_levels(FRSH_RT_LCD,
- 0, &power_levels);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_get_num_power_levels");
+ PXW(frsh_resource_get_num_power_levels(FRSH_RT_LCD, 0, &power_levels));
printf("Number of power levels suppoerted: %d\n", power_levels);
if (power_levels == 1)
PERROR_AND_EXIT(EINVAL, "Different power levels not supported");
-
- printf("Starting...\n");
-
- sleep(5);
- ret = frsh_resource_set_power_level(FRSH_RT_LCD,
- 0, FRSH_PLT_HIGH);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_set_power_level");
- printf("FRSH_PLT_MEDIUM correctly set\n");
-
- sleep(5);
- ret = frsh_resource_set_power_level(FRSH_RT_LCD,
- 0, FRSH_PLT_MEDIUM);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_set_power_level");
- printf("FRSH_PLT_MEDIUM correctly set\n");
-
- sleep(5);
- ret = frsh_resource_set_power_level(FRSH_RT_LCD,
- 0, FRSH_PLT_LOW);
- if (ret) PERROR_AND_EXIT(ret, "frsh_resource_set_power_level");
- printf("FRSH_PLT_LOW correctly set\n");
-
- return 0;
+
+ PXW(frsh_resource_get_power_level(FRSH_RT_LCD, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_LCD, 0, level, &speed));
+ printf("Starting with power level %d, speed = %f\n", level, speed);
+
+ sleep(3);
+ PXW(frsh_resource_set_power_level(FRSH_RT_LCD, 0, FRSH_PLT_HIGH));
+ PXW(frsh_resource_get_power_level(FRSH_RT_LCD, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_LCD, 0, level, &speed));
+ printf("%d (FRSH_PLT_HIGH) correctly set, speed = %f\n", level, speed);
+
+ sleep(3);
+ PXW(frsh_resource_set_power_level(FRSH_RT_LCD, 0, FRSH_PLT_MEDIUM));
+ PXW(frsh_resource_get_power_level(FRSH_RT_LCD, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_LCD, 0, level, &speed));
+ printf("%d (FRSH_PLT_MEDIUM) correctly set, speed = %f\n", level, speed);
+
+ sleep(3);
+ PXW(frsh_resource_set_power_level(FRSH_RT_LCD, 0, FRSH_PLT_LOW));
+ PXW(frsh_resource_get_power_level(FRSH_RT_LCD, 0, &level));
+ PXW(frsh_resource_get_speed(FRSH_RT_LCD, 0, level, &speed));
+ printf("%d (FRSH_PLT_LOW) correctly set, speed = %f\n", level, speed);
+
+ return 0;
}