Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

shellext: viread/viwrite commands to read/write adv7181 registers

  • Loading branch information...
commit 2b38bd5ad5bcc2ea947d55f04eb4eddf9d51e4a2 1 parent 240a360
@sbourdeauducq sbourdeauducq authored
Showing with 90 additions and 15 deletions.
  1. +1 −1  src/main.c
  2. +87 −11 src/shellext.c
  3. +2 −3 src/shellext.h
View
2  src/main.c
@@ -253,7 +253,7 @@ rtems_telnetd_config_table rtems_telnetd_config = {
#define CONFIGURE_SHELL_COMMANDS_INIT
#define CONFIGURE_SHELL_COMMANDS_ALL
#define CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING
-#define CONFIGURE_SHELL_USER_COMMANDS &shell_usercmd, &framebuffer_grab
+#define CONFIGURE_SHELL_USER_COMMANDS &shellext
#include <rtems/shellconfig.h>
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
View
98 src/shellext.c
@@ -19,16 +19,73 @@
#include <rtems.h>
#include <rtems/shell.h>
#include <bsp/milkymist_flash.h>
+#include <bsp/milkymist_video.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdlib.h>
#include <stdio.h>
#include "shellext.h"
#include "fbgrab.h"
+int main_viwrite(int argc, char **argv)
+{
+ unsigned int reg, val;
+ int fd;
+ unsigned int iov;
+
+ if(argc != 3) {
+ fprintf(stderr, "viwrite: you must specify register and value\n");
+ return 1;
+ }
+
+ reg = strtoul(argv[1], NULL, 0);
+ val = strtoul(argv[2], NULL, 0);
+ iov = (reg << 16)|val;
+
+ fd = open("/dev/video", O_RDWR);
+ if(fd == -1) {
+ perror("Unable to open video device");
+ return 2;
+ }
+
+ ioctl(fd, VIDEO_SET_REGISTER, iov);
+
+ close(fd);
+
+ return 0;
+}
+
+int main_viread(int argc, char **argv)
+{
+ int fd;
+ unsigned int rv;
+
+ if(argc != 2) {
+ fprintf(stderr, "viread: you must specify register\n");
+ return 1;
+ }
+
+ rv = strtoul(argv[1], NULL, 0);
+
+ fd = open("/dev/video", O_RDWR);
+ if(fd == -1) {
+ perror("Unable to open video device");
+ return 2;
+ }
+
+ ioctl(fd, VIDEO_GET_REGISTER, &rv);
+
+ close(fd);
+
+ printf("Value: %02x\n", rv);
+
+ return 0;
+}
+
int main_erase(int argc, char **argv)
{
int fd;
@@ -80,18 +137,10 @@ int main_erase(int argc, char **argv)
return 0;
}
-rtems_shell_cmd_t shell_usercmd = {
- "erase", /* name */
- "erase device", /* usage */
- "flickernoise", /* topic */
- main_erase, /* command */
- NULL, /* alias */
- NULL /* next */
-};
-
int main_fbgrab(int argc, char **argv)
{
int ret = 0;
+
if(argc == 2)
ret = fbgrab(argv[1]);
else
@@ -100,11 +149,38 @@ int main_fbgrab(int argc, char **argv)
return ret;
}
-rtems_shell_cmd_t framebuffer_grab = {
+rtems_shell_cmd_t shellext_viwrite = {
+ "viwrite", /* name */
+ "viwrite register value", /* usage */
+ "flickernoise", /* topic */
+ main_viwrite, /* command */
+ NULL, /* alias */
+ NULL /* next */
+};
+
+rtems_shell_cmd_t shellext_viread = {
+ "viread", /* name */
+ "viread register", /* usage */
+ "flickernoise", /* topic */
+ main_viread, /* command */
+ NULL, /* alias */
+ &shellext_viwrite /* next */
+};
+
+rtems_shell_cmd_t shellext_erase = {
+ "erase", /* name */
+ "erase device", /* usage */
+ "flickernoise", /* topic */
+ main_erase, /* command */
+ NULL, /* alias */
+ &shellext_viread /* next */
+};
+
+rtems_shell_cmd_t shellext = {
"fbgrab", /* name */
"fbgrab file.png", /* usage */
"flickernoise", /* topic */
main_fbgrab, /* command */
NULL, /* alias */
- NULL /* next */
+ &shellext_erase /* next */
};
View
5 src/shellext.h
@@ -1,6 +1,6 @@
/*
* Flickernoise
- * Copyright (C) 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
#ifndef __SHELLEXT_H
#define __SHELLEXT_H
-extern rtems_shell_cmd_t shell_usercmd;
-extern rtems_shell_cmd_t framebuffer_grab;
+extern rtems_shell_cmd_t shellext;
#endif /* __SHELLEXT_H */
Please sign in to comment.
Something went wrong with that request. Please try again.