[Armadeus-commitlog] armadeus branch, master, updated. release-3.3-312-g6e06b1b
Brought to you by:
sszy
|
From: Nicolas <th...@us...> - 2011-02-15 15:22:48
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 6e06b1b14267f97e001fcaf8d2c05e61a12d02be (commit)
from 0aa57e2a8f7c19bcde241b840a537b7673aece20 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6e06b1b14267f97e001fcaf8d2c05e61a12d02be
Author: Nicolas Colombain <nic...@ar...>
Date: Tue Feb 15 16:20:15 2011 +0100
[BUILDROOT] add tfp410ctrl user space program for APF51Dev
-----------------------------------------------------------------------
Summary of changes:
buildroot/package/armadeus/Config.in | 1 +
buildroot/package/armadeus/tfp410ctrl/Config.in | 8 +
buildroot/package/armadeus/tfp410ctrl/tfp410.mk | 41 +++
.../packages/{ch7024ctrl => tfp410ctrl}/Makefile | 14 +-
target/packages/tfp410ctrl/tfp410ctrl.c | 368 ++++++++++++++++++++
.../packages/tfp410ctrl/tfp410ctrl.h | 44 ++-
6 files changed, 454 insertions(+), 22 deletions(-)
create mode 100644 buildroot/package/armadeus/tfp410ctrl/Config.in
create mode 100644 buildroot/package/armadeus/tfp410ctrl/tfp410.mk
copy target/packages/{ch7024ctrl => tfp410ctrl}/Makefile (67%)
create mode 100644 target/packages/tfp410ctrl/tfp410ctrl.c
copy software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h => target/packages/tfp410ctrl/tfp410ctrl.h (53%)
mode change 100755 => 100644
diff --git a/buildroot/package/armadeus/Config.in b/buildroot/package/armadeus/Config.in
index d03f031..11e7d09 100644
--- a/buildroot/package/armadeus/Config.in
+++ b/buildroot/package/armadeus/Config.in
@@ -1,6 +1,7 @@
menu "Armadeus specific tools/utilities"
source package/armadeus/ad9889ctrl/Config.in
+source package/armadeus/tfp410ctrl/Config.in
source package/armadeus/as_devices/Config.in
source package/armadeus/ch7024ctrl/Config.in
source package/armadeus/demos/Config.in
diff --git a/buildroot/package/armadeus/tfp410ctrl/Config.in b/buildroot/package/armadeus/tfp410ctrl/Config.in
new file mode 100644
index 0000000..e60d138
--- /dev/null
+++ b/buildroot/package/armadeus/tfp410ctrl/Config.in
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_TFP410CTRL
+ bool "tfp410ctrl"
+ depends on BR2_TARGET_ARMADEUS
+ default n
+ help
+ Build TFP410 control tool. It allows you to configure the HDMI/DVI
+ output of the APF51Dev directly from Linux userspace (command tfp410ctrl).
+
diff --git a/buildroot/package/armadeus/tfp410ctrl/tfp410.mk b/buildroot/package/armadeus/tfp410ctrl/tfp410.mk
new file mode 100644
index 0000000..0dee387
--- /dev/null
+++ b/buildroot/package/armadeus/tfp410ctrl/tfp410.mk
@@ -0,0 +1,41 @@
+#############################################################
+#
+# tfp410 control tool
+#
+#############################################################
+
+TFP410CTRL_VER:=1.0
+TFP410CTRL_SOURCE:=$(TOPDIR)/../target/packages/tfp410ctrl
+TFP410CTRL_DIR:=$(BUILD_DIR)/tfp410ctrl-$(TFP410CTRL_VER)
+TFP410CTRL_CAT:=zcat
+TFP410CTRL_BINARY:=tfp410ctrl
+TFP410CTRL_TARGET_BINARY:=usr/bin/tfp410ctrl
+
+$(TFP410CTRL_DIR)/tfp410ctrl.c:
+ mkdir -p $(TFP410CTRL_DIR)/
+ cp $(TFP410CTRL_SOURCE)/* $(TFP410CTRL_DIR)/
+
+$(TFP410CTRL_DIR)/$(TFP410CTRL_BINARY): $(TFP410CTRL_DIR)/tfp410ctrl.c $(TFP410CTRL_DIR)/tfp410ctrl.h
+ $(MAKE) CC="$(TARGET_CC)" -C $(TFP410CTRL_DIR)
+
+$(TARGET_DIR)/$(TFP410CTRL_TARGET_BINARY): $(TFP410CTRL_DIR)/$(TFP410CTRL_BINARY)
+ install -D $< $@
+ $(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/$(TFP410CTRL_TARGET_BINARY)
+
+tfp410ctrl: $(TARGET_DIR)/$(TFP410CTRL_TARGET_BINARY)
+
+tfp410ctrl-clean:
+ rm -f $(TARGET_DIR)/$(TFP410CTRL_TARGET_BINARY)
+ -$(MAKE) -C $(TFP410CTRL_DIR) clean
+
+tfp410ctrl-dirclean:
+ rm -rf $(TFP410CTRL_DIR)
+
+#############################################################
+#
+# Toplevel Makefile options
+#
+#############################################################
+ifeq ($(strip $(BR2_PACKAGE_TFP410CTRL)),y)
+TARGETS+=tfp410ctrl
+endif
diff --git a/target/packages/ch7024ctrl/Makefile b/target/packages/tfp410ctrl/Makefile
similarity index 67%
copy from target/packages/ch7024ctrl/Makefile
copy to target/packages/tfp410ctrl/Makefile
index 36cf434..51569b1 100644
--- a/target/packages/ch7024ctrl/Makefile
+++ b/target/packages/tfp410ctrl/Makefile
@@ -1,5 +1,5 @@
#
-# Makefile for the Armadeus SVIDEO controler CH7024
+# Makefile for the Armadeus HDMI/DVI controler TFP410
#
CFLAGS = -Wall -O
@@ -10,10 +10,10 @@ PWD := $(shell pwd)
#HEADERS =
-SOURCES = ch7024.c
-OBJECTS = ch7024.o
+SOURCES = tfp410ctrl.c
+OBJECTS = tfp410ctrl.o
-TARGET = ch7024
+TARGET = tfp410ctrl
####### Implicit rules
@@ -41,7 +41,7 @@ TARGET = ch7024
$(TARGET): $(OBJECTS) Makefile $(HEADERS)
@echo
- @echo "Building CH7024 control programm..."
+ @echo "Building tfp410ctrl control programm..."
$(CC) $(OBJECTS) $(CFLAGS) $(INCLUDES) -o $(TARGET)
@@ -51,9 +51,9 @@ clean:
-rm -f $(TARGET)
-rm -f *.o *~ core
-ch7024.o: ch7024.c ch7024.h Makefile
+tfp410ctrl.o: tfp410ctrl.c tfp410ctrl.h Makefile
@echo
- $(CC) -c $(CFLAGS) $(INCLUDES) ch7024.c
+ $(CC) -c $(CFLAGS) $(INCLUDES) tfp410ctrl.c
diff --git a/target/packages/tfp410ctrl/tfp410ctrl.c b/target/packages/tfp410ctrl/tfp410ctrl.c
new file mode 100644
index 0000000..087abf0
--- /dev/null
+++ b/target/packages/tfp410ctrl/tfp410ctrl.c
@@ -0,0 +1,368 @@
+/*
+** ARMADEUS Systems
+**
+** Copyright (C) 2011 The source forge armadeus systems team
+**
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** tfp410ctrl: manage the TFP410 Video controller
+**
+** authors: th...@us...
+*/
+
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-dev.h>
+
+#include <sys/ioctl.h>
+#include "tfp410ctrl.h"
+#define DEBUG_TFP410 1
+
+#define VERSION "0.2alpha"
+#define CONF_FILE "tfp410.conf"
+#define MAX_DUMP_LINE 100
+/****************************************************************************************************************************/
+
+/* MENU */
+void usage()
+{
+ printf("\ntfp410ctrl utility ver %s Armadeus\n", VERSION);
+ printf("q: quit\n");
+ printf("m: modify\n");
+ printf("d: dump tfp410 registers\n");
+ printf("s: save\n");
+ printf("l: load\n");
+ printf("other: this menu\n");
+}
+
+void registerMenu()
+{
+ printf("\n1. CTL_1_MODE");
+ printf("\n2. CTL_2_MODE");
+ printf("\n3. CTL_3_MODE");
+ printf("\n4. CFG");
+ printf("\n5. DE_DLY");
+ printf("\n6. DE_CTL");
+ printf("\n7. DE_TOP");
+ printf("\n8. DE_CNT");
+ printf("\n9. DE_LIN\n");
+}
+
+
+static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
+ int size, union i2c_smbus_data *data)
+{
+ struct i2c_smbus_ioctl_data args;
+
+ args.read_write = read_write;
+ args.command = command;
+ args.size = size;
+ args.data = data;
+ return ioctl(file, I2C_SMBUS, &args);
+}
+
+/* Read a byte on the I2C bus
+ This is done by writing the register address
+ we want to access and then by reading this register
+ @param fd: file descriptor of the device
+ @param dev: address of the device on I2C bus
+ @param reg: register to access
+ @param buf: buffer used to store the result
+ @return : -1 in case of error otherwise 0
+ */
+int read_byte(int fd, unsigned char dev, unsigned char reg, unsigned char *buf)
+{
+ union i2c_smbus_data data;
+
+ /* configure I2C_SLAVE */
+ if (ioctl(fd, I2C_SLAVE, dev) < 0) {
+ perror("Ioctl error: ");
+ return -1;
+ }
+
+ if (i2c_smbus_access(fd, I2C_SMBUS_READ, reg,
+ I2C_SMBUS_BYTE_DATA, &data)) {
+ printf("Read error\n");
+ return -1;
+ } else {
+ *buf = 0x0FF & data.byte;
+ return 0;
+ }
+}
+
+int read_word(int fd, unsigned char dev, unsigned char reg, unsigned short *buf)
+{
+ union i2c_smbus_data data;
+
+ /* configure I2C_SLAVE */
+ if (ioctl(fd, I2C_SLAVE, dev) < 0) {
+ perror("Ioctl error: ");
+ return -1;
+ }
+
+ if (i2c_smbus_access(fd, I2C_SMBUS_READ, reg,
+ I2C_SMBUS_WORD_DATA, &data)) {
+ printf("Read error\n");
+ return -1;
+ } else {
+ *buf = 0xFFFF & data.word;
+ return 0;
+ }
+}
+
+
+/* Write a byte on the I2C bus
+ @param fd: file descriptor of the device
+ @param dev: address of the device on I2C bus
+ @param reg: register to access
+ @param value: value to write
+ @return : -1 in case of error otherwise 0
+ */
+int write_byte(int fd, unsigned char dev, unsigned char reg, unsigned char value)
+{
+ union i2c_smbus_data data;
+ data.byte = value;
+
+ /* configure I2C_SLAVE */
+ if (ioctl(fd, I2C_SLAVE, dev) < 0) {
+ perror("Ioctl error: ");
+ return -1;
+ }
+
+ return i2c_smbus_access(fd, I2C_SMBUS_WRITE, reg,
+ I2C_SMBUS_BYTE_DATA, &data);
+
+ return 0;
+}
+
+int write_word(int fd, unsigned char dev, unsigned char reg, unsigned short value)
+{
+ union i2c_smbus_data data;
+ data.word = value;
+
+ /* configure I2C_SLAVE */
+ if (ioctl(fd, I2C_SLAVE, dev) < 0) {
+ perror("Ioctl error: ");
+ return -1;
+ }
+
+ return i2c_smbus_access(fd, I2C_SMBUS_WRITE, reg,
+ I2C_SMBUS_WORD_DATA, &data);
+
+ return 0;
+}
+
+/* dump the register values on the screen if destFile is NULL or in a file
+ */
+void dumpReg(int fd, int regAddr, char* info, FILE* destFile)
+{
+ unsigned short buf = 0;
+ char dumpString[MAX_DUMP_LINE];
+
+ if (regAddr > DE_TOP_REG)
+ read_word(fd, TFP410_I2C_SLAVE_ADDR, regAddr, &buf);
+ else
+ read_byte(fd, TFP410_I2C_SLAVE_ADDR, regAddr, (unsigned char*)&buf);
+
+ if (destFile == NULL){
+ sprintf(dumpString, "%s %02X:%04X\t", info, regAddr, buf);
+ printf("%s\n", dumpString);
+ } else {
+ sprintf(dumpString, "%02X:%04X\t", regAddr, buf);
+ fprintf(destFile, "%s\n", dumpString);
+ }
+}
+
+/* dump the register values on the screen if destFile is NULL or in a file
+ @param fd: file descriptor of the TFP410
+ @param destFile: file in which to write if used otherwise ""
+ */
+void dump(int fd, FILE* destFile)
+{
+
+ if (destFile == NULL)
+ printf("\t\t Ad:Va\n");
+
+ dumpReg(fd, CTL_1_MODE_REG, "CTL_1_MODE:\t", destFile);
+ dumpReg(fd, CTL_2_MODE_REG, "CTL_2_MODE:\t", destFile);
+ dumpReg(fd, CTL_3_MODE_REG, "CTL_3_MODE:\t", destFile);
+ dumpReg(fd, CFG_REG, "CFG:\t\t", destFile);
+ dumpReg(fd, DE_DLY_REG, "DE_DLY:\t\t", destFile);
+ dumpReg(fd, DE_CTL_REG, "DE_CTL:\t\t", destFile);
+ dumpReg(fd, DE_TOP_REG, "DE_TOP:\t\t", destFile);
+ dumpReg(fd, DE_CNT_REG, "DE_CNT:\t\t", destFile);
+ dumpReg(fd, DE_LIN_REG, "DE_LIN:\t\t", destFile);
+ dumpReg(fd, H_RES_REG, "H_RES:\t\t", destFile);
+ dumpReg(fd, V_RES_REG, "V_RES:\t\t", destFile);
+}
+
+/* load the TFP410 registers with the values contained in the given file
+ @param fd: file descriptor of the TFP410
+ @param fileName: file containing the values. If "" then the name has to be entered
+ */
+void load(int fd, char* fileName)
+{
+ char line[MAX_DUMP_LINE];
+ char tempFileName[MAX_DUMP_LINE];
+ FILE *fd_conf = NULL;
+ unsigned int regAddr, val;
+
+ if (strlen(fileName) == 0) {
+ printf("Enter file name: ");
+ fgets(tempFileName, sizeof(tempFileName), stdin);
+ tempFileName[strlen(tempFileName)-1] = '\0'; /* suppress \n */
+ }
+ else {
+ strcpy(tempFileName, fileName);
+ }
+
+ if ((fd_conf = fopen(tempFileName, "r")) == NULL) {
+ perror("Open error: ");
+ exit (1);
+ }
+ while (fgets(line, MAX_DUMP_LINE, fd_conf) != NULL) {
+ sscanf(line,"%2X%*c%4X", ®Addr, &val);
+ printf("reg %02x, value %04x\n", regAddr, val);
+ if (regAddr > DE_TOP_REG)
+ write_word (fd, TFP410_I2C_SLAVE_ADDR, regAddr, val);
+ else
+ write_byte (fd, TFP410_I2C_SLAVE_ADDR, regAddr, val);
+ }
+ if (fd_conf != NULL)
+ fclose(fd_conf);
+}
+
+void modifyRegister(int fd, int regAddr)
+{
+ int regValue;
+ char string[10]; // user input string
+
+ printf("Reg value:");
+ fgets(string, sizeof(string), stdin);
+ if ((regAddr == DE_CNT_REG) || (regAddr == DE_LIN_REG)) {
+ sscanf(string, "%4x", ®Value);
+ write_word(fd, TFP410_I2C_SLAVE_ADDR, regAddr, regValue);
+ } else {
+ sscanf(string, "%2x", ®Value);
+ write_byte(fd, TFP410_I2C_SLAVE_ADDR, regAddr, regValue);
+ }
+}
+
+void tfp410_init( int fd )
+{
+ /* exit power down mode */
+ write_byte(fd, TFP410_I2C_SLAVE_ADDR, CTL_1_MODE_REG, 0xBD);
+ /* configure MSEN/PO1 as hotplug detect pin */
+ write_byte(fd, TFP410_I2C_SLAVE_ADDR, CTL_2_MODE_REG, 0x32);
+
+}
+
+int main(int argc, char *argv[])
+{
+ int fd; // TFP410 file descriptor
+ FILE *fd_conf = NULL; // config file
+ char string[10]; // user input string
+ unsigned short buf; // buf to store I2C command/data
+ char* bus = "/dev/i2c-1";
+
+ if (argc > 2) { /* too many args */
+ usage();
+ exit(1);
+ } else if (argc == 2) { /* i2c bus */
+ bus = argv[1];
+ }
+
+ /* open I2C /dev */
+ if ((fd = open(bus, O_RDWR)) < 0) {
+ perror("Open error: ");
+ exit (1);
+ }
+
+ /* configure I2C_SLAVE */
+ if (ioctl(fd, I2C_SLAVE, TFP410_I2C_SLAVE_ADDR) < 0) {
+ perror("Ioctl error: ");
+ exit (1);
+ }
+
+ /* check TFP410 presence */
+ if (!read_word(fd, TFP410_I2C_SLAVE_ADDR, DEV_ID_REG, &buf)) {
+ printf("DEV_ID = %x\n", buf);
+ if ((DEV_ID != buf)) {
+ printf("incorrect dev id. Exiting\n");
+ exit(1);
+ }
+ } else {
+ printf("TFP410 not found. Exiting\n");
+ exit(1);
+ }
+
+ tfp410_init(fd);
+ usage();
+ while(1) {
+ fgets(string, sizeof(string), stdin);
+ if (string[0] == 'q') { /* Exit */
+ exit(0);
+ }
+ else if (string[0] == 'm') { /* Modify registers */
+ registerMenu();
+ fgets(string, sizeof(string), stdin);
+ switch (string[0]){
+ case '1': modifyRegister(fd, CTL_1_MODE_REG); break;
+ case '2': modifyRegister(fd, CTL_2_MODE_REG); break;
+ case '3': modifyRegister(fd, CTL_3_MODE_REG); break;
+ case '4': modifyRegister(fd, CFG_REG); break;
+ case '5': modifyRegister(fd, DE_DLY_REG); break;
+ case '6': modifyRegister(fd, DE_CTL_REG); break;
+ case '7': modifyRegister(fd, DE_TOP_REG); break;
+ case '8': modifyRegister(fd, DE_CNT_REG); break;
+ case '9': modifyRegister(fd, DE_LIN_REG); break;
+ default: printf("invalid selection\n"); break;
+ }
+ }
+ else if (string[0] == 'd') { /* Dump to screen */
+ dump(fd, fd_conf);
+ }
+ else if (string[0] == 's') { /* Save to file */
+ if ((fd_conf = fopen(CONF_FILE, "w")) < 0) {
+ perror("Open error: ");
+ exit (1);
+ }
+ dump(fd, fd_conf);
+ if (fd_conf != NULL) {
+ fclose(fd_conf);
+ }
+ printf("Data saved to conf file\n");
+ }
+ else if (string[0] == 'l') { /* load from file */
+ load(fd, "");
+ } else {
+ usage();
+ }
+ };
+
+ if (fd >= 0) {
+ close(fd);
+ }
+
+ exit (0);
+}
+
diff --git a/software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h b/target/packages/tfp410ctrl/tfp410ctrl.h
old mode 100755
new mode 100644
similarity index 53%
copy from software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h
copy to target/packages/tfp410ctrl/tfp410ctrl.h
index 083d5cc..617348b
--- a/software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h
+++ b/target/packages/tfp410ctrl/tfp410ctrl.h
@@ -1,7 +1,7 @@
/*
-** THE ARMADEUS PROJECT
+** ARMADEUS Systems
**
-** Copyright (2006) The source forge armadeus project team
+** Copyright (C) 2011 year The source forge armadeus systems team
**
** 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
@@ -17,23 +17,37 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** ApfNetworkDefs.h
+** File : tfp410ctrl.h
**
-** author: ca...@us...
+** authors: th...@us...
*/
+
+// I2C slave Adresses
-#ifndef __APFNETWORKDEFS_H_INCLUDED__
-#define __APFNETWORKDEFS_H_INCLUDED__
+#define TFP410_I2C_SLAVE_ADDR 0x38
+
+
+// main registers address
+#define VEN_ID 0x014C
+#define DEV_ID 0x410
+#define REV_ID 0x0000
+
+
+#define VEN_ID_REG 0x00
+#define DEV_ID_REG 0x02
+#define REV_ID_REG 0x04
+#define CTL_1_MODE_REG 0x08
+#define CTL_2_MODE_REG 0x09
+#define CTL_3_MODE_REG 0x0A
+#define CFG_REG 0x0B
+#define DE_DLY_REG 0x32
+#define DE_CTL_REG 0x33
+#define DE_TOP_REG 0x34
+#define DE_CNT_REG 0x36
+#define DE_LIN_REG 0x38
+#define H_RES_REG 0x3A
+#define V_RES_REG 0x3C
-namespace ApfNetworkDefs
-{
- // The Dynamic and/or Private Ports are those from 49152 through 65535
- static const unsigned int APF_SOCKET = 50154; //why not ?
- static const unsigned int DATASTREAM_RELEASE = 5;
- static const int MIN_DAC = 0;
- static const int MAX_DAC = 32;
-}
-#endif // __APFNETWORKDEFS_H_INCLUDED__
hooks/post-receive
--
armadeus
|