/
dev_daddymax.c
106 lines (80 loc) · 2.87 KB
/
dev_daddymax.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Support code for the DaddyMax DMX512 dongle.
*
* Copyright (c) 1999 Lighting and Sound Technologies.
* Written by Ryan C. Gordon.
*/
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include "boolean.h"
#include "dimmer.h"
static struct DimmerDeviceInfo devInfo;
static void daddymax_queryModName(char *buffer, int bufSize)
{
printf("daddymax_queryModName(%p, %d)\n", buffer, bufSize);
strncpy(buffer, "daddymax_kernel", bufSize);
buffer[bufSize - 1] = '\0'; /* promises null termination. */
} /* daddymax_queryModName */
static void daddymax_updateDevice(unsigned char *levels)
{
printf("daddymax_updateDevice(%p)\n", levels);
} /* daddymax_updateDevice */
static int daddymax_queryExistence(void)
{
int retVal = 0;
struct stat statInfo;
printf("daddymax_queryExistence()\n");
if (stat("/dev/daddymax", &statInfo) != -1)
{
if (statInfo.st_mode & S_IFCHR) /* character device? */
retVal = 1;
} /* if */
return(retVal);
} /* daddymax_queryExistence */
static int daddymax_queryDevice(struct DimmerDeviceInfo *info)
{
printf("daddymax_queryDevice(%p)\n", info);
memcpy(info, &devInfo, sizeof (struct DimmerDeviceInfo));
return(0);
} /* daddymax_queryDevice */
static int daddymax_initialize(void)
{
printf("daddymax_initialize()\n");
memset(&devInfo, '\0', sizeof (struct DimmerDeviceInfo));
//open("/dev/daddymax", O_RDWR);
devInfo.numOutputs = 1; /* !!! lose this later! */
devInfo.numChannels = 512;
devInfo.isDuplexed = 0;
return(0);
} /* daddymax_initialize */
static void daddymax_deinitialize(void)
{
printf("daddymax_deinitialize()\n");
} /* daddymax_deinitialize */
static int daddymax_channelSet(int channel, int intensity)
{
printf("daddymax_channelSet(%d, %d)\n", channel, intensity);
return(0);
} /* daddymax_channelSet */
static int daddymax_setDuplexMode(__boolean shouldSet)
{
printf("daddymax_setDuplexMode(%s)\n", shouldSet ? "__true" : "__false");
return(-1);
} /* setDuplexMode */
/*
* This struct is down here so I don't need
* prototypes of all these functions...
*/
struct DimmerDeviceFunctions daddymax_funcs = {
daddymax_queryModName,
daddymax_queryExistence,
daddymax_queryDevice,
daddymax_initialize,
daddymax_deinitialize,
daddymax_channelSet,
daddymax_setDuplexMode,
daddymax_updateDevice
};
/* end of dev_daddymax.c ... */