KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
dreameye.h
Go to the documentation of this file.
1 /* KallistiOS 2.0.0
2 
3  dc/maple/dreameye.h
4  Copyright (C) 2005, 2009, 2010 Lawrence Sebald
5 
6 */
7 
8 /** \file dc/maple/dreameye.h
9  \brief Definitions for using the Dreameye Camera device.
10 
11  This file contains the definitions needed to access the Maple Camera type
12  device (aka, the Dreameye). Currently, this driver allows you to download
13  the still pictures that are saved on the camera and delete them. It does not
14  allow you to use the camera for video input currently.
15 
16  \author Lawrence Sebald
17 */
18 
19 #ifndef __DC_MAPLE_DREAMEYE_H
20 #define __DC_MAPLE_DREAMEYE_H
21 
22 #include <sys/cdefs.h>
23 __BEGIN_DECLS
24 
25 #include <arch/types.h>
26 #include <dc/maple.h>
27 
28 /** \brief Dreameye status structure.
29 
30  This structure contains information about the status of the Camera device
31  and can be fetched with maple_dev_status(). You should not change any of
32  this information, it should all be considered read-only. Most of the fields
33  in here are related to image transfers, and messing with them during a
34  transfer could screw things up.
35 
36  \headerfile dc/maple/dreameye.h
37 */
38 typedef struct dreameye_state {
39  /** \brief The number of images on the device. */
41 
42  /** \brief Is the image_count field valid? */
44 
45  /** \brief The number of transfer operations required for the selected
46  image. */
48 
49  /** \brief Is an image transferring now? */
51 
52  /** \brief Storage for image data. */
54 
55  /** \brief The size of the image in bytes. */
56  int img_size;
57 
58  /** \brief The image number currently being transferred. */
61 
62 /** \brief Get the number of images on the device.
63 
64  This constant is used with the MAPLE_COMMAND_GETCOND command to fetch the
65  number of images on the device.
66 */
67 #define DREAMEYE_GETCOND_NUM_IMAGES 0x81
68 
69 /** \brief Get the number of transfers to copy an image.
70 
71  This constant is used with the MAPLE_COMMAND_GETCOND command to fetch the
72  number of times a transfer command must be sent to get the image specified.
73 */
74 #define DREAMEYE_GETCOND_TRANSFER_COUNT 0x83
75 
76 /** \brief Get an image from the device.
77 
78  This subcommand is used with the MAPLE_COMMAND_CAMCONTROL command to fetch
79  part of image data from the specified image.
80 */
81 #define DREAMEYE_SUBCOMMAND_IMAGEREQ 0x04
82 
83 /** \brief Erase an image from the device.
84 
85  This subcommand is used with the MAPLE_COMMAND_CAMCONTROL command to remove
86  an image from the device.
87 */
88 #define DREAMEYE_SUBCOMMAND_ERASE 0x05
89 
90 /** \brief Error return command.
91 
92  This subcommand is used by the dreameye with the MAPLE_COMMAND_CAMCONTROL
93  command to indicate an error occurred in a subcommand.
94 */
95 #define DREAMEYE_SUBCOMMAND_ERROR 0xFF
96 
97 /** \brief Continue transferring an image. */
98 #define DREAMEYE_IMAGEREQ_CONTINUE 0x00
99 
100 /** \brief Start transferring an image from its start. */
101 #define DREAMEYE_IMAGEREQ_START 0x40
102 
103 /** \brief Get the number of images on the Dreameye.
104 
105  This function fetches the number of saved images on the specified Dreameye
106  device. It can be sent to any of the subdevices of the MAPLE_FUNC_CONTROLLER
107  root device of the Dreameye. When the response comes from the device, the
108  image_count field of the dreameye_state_t for the specified device will have
109  the number of images on the device, and image_count_valid will be set to 1.
110 
111  \param dev The device to query.
112  \param block Set to 1 to wait for the Dreameye to respond.
113  \retval MAPLE_EOK On success.
114  \retval MAPLE_ETIMEOUT The command timed out while blocking.
115  \retval MAPLE_EAGAIN Could not send the command to the device, try again.
116 */
117 int dreameye_get_image_count(maple_device_t *dev, int block);
118 
119 /** \brief Transfer an image from the Dreameye.
120 
121  This function fetches a single image from the specified Dreameye device.
122  This function will block, and can take a little while to execute. You must
123  use the first subdevice of the MAPLE_FUNC_CONTROLLER root device of the
124  Dreameye as the dev parameter.
125 
126  \param dev The device to get an image from.
127  \param image The image number to download.
128  \param data A pointer to a buffer to store things in. This
129  will be allocated by the function and you are
130  responsible for freeing the data when you are done.
131  \param img_sz A pointer to storage for the size of the image, in
132  bytes.
133  \retval MAPLE_EOK On success.
134  \retval MAPLE_EFAIL On error.
135 */
136 int dreameye_get_image(maple_device_t *dev, uint8 image, uint8 **data,
137  int *img_sz);
138 
139 /** \brief Erase an image from the Dreameye.
140 
141  This function erases the specified image from the Dreameye device. This
142  command can be sent to any of the subdevices of the MAPLE_FUNC_CONTROLLER
143  root device of the Dreameye.
144 
145  \param dev The device to erase from.
146  \param image The image number to erase (0xFF to erase all).
147  \param block Set to 1 to wait for the Dreameye to respond.
148  \retval MAPLE_EOK On success.
149  \retval MAPLE_EAGAIN Couldn't send the command, try again.
150  \retval MAPLE_ETIMEOUT Timeout on blocking.
151  \retval MAPLE_EINVALID Invalid image number specified.
152 */
153 int dreameye_erase_image(maple_device_t *dev, uint8 image, int block);
154 
155 /* \cond */
156 /* Init / Shutdown */
157 int dreameye_init();
158 void dreameye_shutdown();
159 /* \endcond */
160 
161 __END_DECLS
162 
163 #endif /* __DC_MAPLE_DREAMEYE_H */