27 #include <sys/types.h> 35 static void usage(
char *name)
37 printf(
"usage: %s [OPTIONS]\n\n", name);
39 printf(
"\t-d <index>\t\tthe device index (default is 0)\n");
40 printf(
"\t-f <filename>\t\tthe image file to upload\n");
41 printf(
"\t-F <format>\t\tthe image format to use (default is JPEG)\n");
42 printf(
"\t\t\t\tSUPPORTED FORMATS:\n");
43 printf(
"\t\t\t\t\t1 - JPEG\n");
44 printf(
"\t\t\t\t\t2 - NV12\n");
45 printf(
"\t-l <log level>\t\tthe verbosity level of libam7xxx output (0-5)\n");
46 printf(
"\t-p <power mode>\t\tthe power mode of device, between %d (off) and %d (turbo)\n",
48 printf(
"\t\t\t\tWARNING: Level 2 and greater require the master AND\n");
49 printf(
"\t\t\t\t the slave connector to be plugged in.\n");
50 printf(
"\t-z <zoom mode>\t\tthe display zoom mode, between %d (original) and %d (tele)\n",
52 printf(
"\t-W <image width>\tthe width of the image to upload\n");
53 printf(
"\t-H <image height>\tthe height of the image to upload\n");
54 printf(
"\t-h \t\t\tthis help message\n");
55 printf(
"\n\nEXAMPLE OF USE:\n");
56 printf(
"\t%s -f file.jpg -F 1 -l 5 -W 800 -H 480\n", name);
59 int main(
int argc,
char *argv[])
64 char filename[FILENAME_MAX] = {0};
80 while ((opt = getopt(argc, argv,
"d:f:F:l:p:z:W:H:h")) != -1) {
83 device_index = atoi(optarg);
84 if (device_index < 0) {
85 fprintf(stderr,
"Unsupported device index\n");
91 if (filename[0] !=
'\0')
92 fprintf(stderr,
"Warning: image file already specified\n");
93 strncpy(filename, optarg, FILENAME_MAX);
96 format = atoi(optarg);
99 fprintf(stdout,
"JPEG format\n");
102 fprintf(stdout,
"NV12 format\n");
105 fprintf(stderr,
"Unsupported format\n");
111 log_level = atoi(optarg);
113 fprintf(stderr,
"Unsupported log level, falling back to AM7XXX_LOG_ERROR\n");
118 power_mode = atoi(optarg);
125 fprintf(stdout,
"Power mode: %d\n", power_mode);
128 fprintf(stderr,
"Invalid power mode value, must be between %d and %d\n",
142 fprintf(stdout,
"Zoom: %d\n", zoom);
145 fprintf(stderr,
"Invalid zoom mode value, must be between %d and %d\n",
152 width = atoi(optarg);
154 fprintf(stderr,
"Unsupported width\n");
160 height = atoi(optarg);
162 fprintf(stderr,
"Unsupported height\n");
178 if (filename[0] ==
'\0') {
179 fprintf(stderr,
"An image file MUST be specified with the -f option.\n\n");
185 image_fp = fopen(filename,
"rb");
186 if (image_fp == NULL) {
191 ret = fstat(fileno(image_fp), &st);
194 goto out_close_image_fp;
198 image = malloc(size *
sizeof(
unsigned char));
202 goto out_close_image_fp;
205 ret = (int)fread(image, size, 1, image_fp);
208 fprintf(stderr,
"Unexpected end of file.\n");
209 else if (ferror(image_fp))
212 fprintf(stderr,
"Unexpected error condition.\n");
221 perror(
"am7xxx_init");
229 perror(
"am7xxx_open_device");
235 perror(
"am7xxx_close_device");
241 perror(
"am7xxx_open_device");
247 perror(
"am7xxx_get_device_info");
250 printf(
"Native resolution: %dx%d\n",
255 perror(
"am7xxx_set_zoom_mode");
261 perror(
"am7xxx_set_power_mode");
267 printf(
"AM7XXX_ZOOM_TEST requested, not sending actual image.\n");
274 "WARNING: image is %dx%d, not fitting the native resolution, it may be displayed wrongly!\n",
279 perror(
"am7xxx_send_image");
292 if (fclose(image_fp) == EOF)
Zoom test screen, the firmware version is shown as well.
Zoom 1: H Scale (changes aspect ratio).
struct _am7xxx_context am7xxx_context
An opaque data type representing a context.
Zoom Tele: available on some PicoPix models.
A struct describing device specific properties.
int am7xxx_init(am7xxx_context **ctx)
Initialize the library context and data structures, and scan for devices.
Original Size, as retrieved via am7xxx_device_info.
Max brightness and power consumption.
Middle level of brightness.
int am7xxx_open_device(am7xxx_context *ctx, am7xxx_device **dev, unsigned int device_index)
Open an am7xxx_device according to a index.
Zoom 2: H/V Scale (changes aspect ratio).
More brightness, but more power consumption.
Error messages, typically they describe API functions failures.
int am7xxx_set_power_mode(am7xxx_device *dev, am7xxx_power_mode power)
Set the power mode of an am7xxx device.
void am7xxx_set_log_level(am7xxx_context *ctx, am7xxx_log_level log_level)
Set verbosity level of log messages.
int am7xxx_get_device_info(am7xxx_device *dev, am7xxx_device_info *device_info)
Get info about an am7xxx device.
unsigned int native_width
The device native width.
Informations about the device operations.
int am7xxx_set_zoom_mode(am7xxx_device *dev, am7xxx_zoom_mode zoom)
Set the zoom mode of an am7xxx device.
Raw YUV in the NV12 variant.
Verbose informations about the communication with the hardware.
Low power consumption but also low brightness.
int am7xxx_send_image(am7xxx_device *dev, am7xxx_image_format format, unsigned int width, unsigned int height, unsigned char *image, unsigned int image_size)
Send an image for display on an am7xxx device.
unsigned int native_height
The device native height.
void am7xxx_shutdown(am7xxx_context *ctx)
Cleanup the library data structures and free the context.
int am7xxx_close_device(am7xxx_device *dev)
Close an am7xxx_device.
struct _am7xxx_device am7xxx_device
An opaque data type representing an am7xxx device.
Display is powered off, no image shown.