1 /* sierra_desc.h: 2 * 3 * Copyright 2002 Patrick Mansfield <patman@aracnet.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301 USA 19 */ 20 21 /* 22 * Define a set of structures to describe the register layouts of a 23 * digital camera, based on the Nikon Coolpix 880 (sierra). Only camera 24 * configuration/settings are handled here. 25 * 26 * The lowest level structs are first, followed by the higher levels. 27 * 28 * These structures can't be in one single struct, since they are variable 29 * length, and each level has a slightly different set of functionality. 30 * 31 * Generally, we have a CameraRegisterSetType with pointers to 32 * CameraRegisterType registers; each register in turn has pointers to 33 * RegisterDescriptorType's; each RegisterDescriptorType has pointers to 34 * ValueNameType's; the ValueNameType is a value and corresponding 35 * description (string). 36 */ 37 38 #ifndef __SIERRA_DESC_H__ 39 #define __SIERRA_DESC_H__ 40 41 #define SIZE_ADDR(type, var) (sizeof(var)/sizeof(type)), (type*) var 42 43 #define VAL_NAME_INIT(name) \ 44 SIZE_ADDR(ValueNameType, name) 45 46 #define CAM_REG_TYPE_INIT(prefix, reg, rsize, get_set, action) \ 47 { reg, rsize, 0, { get_set, action }, \ 48 SIZE_ADDR(RegisterDescriptorType, prefix##_reg_##reg), \ 49 } 50 51 #define GP_REG_NO_MASK ~0 /* XXX long or int or ? */ 52 53 typedef enum { 54 CAM_DESC_DEFAULT, /* use standard sierra get/set int/string 55 functions, depending on reg_len */ 56 CAM_DESC_SUBACTION, /* use standard get int/string, but use the 57 sierr_sub_action to set values */ 58 } RegGetSetType; 59 60 typedef struct { 61 RegGetSetType method; 62 int action; /* if we are CAM_DESC_ACTION, the action to use. 63 * The sub-action is stored in the name-value 64 * field. This is probably not good enough for the 65 * standard action (calling sierra_action versus 66 * calling sierra_sub_action). 67 */ 68 } GetSetType; 69 70 typedef struct { 71 union { 72 /* 73 * The register value masked with regs_mask gives the 74 * register value to compare or use here. Register values 75 * are always int, and must be converted to/from float for 76 * range values. The proper value to user here is based 77 * on the reg_len size and the reg_widget_type. 78 * 79 * For fields like the exp compensation, or the zoom, 80 * where the first x bytes are used, and it looks like the 81 * rest are a fixed value: just mask them out, and use the 82 * values read from the camera. 83 */ 84 int64_t value; /* GP_WIDGET_RADIO */ 85 float range[3]; /* GP_WIDGET_RANGE these are 86 min/max/stepping; if stepping is zero, 87 a stepping of one is used. */ 88 CameraWidgetCallback callback; /* GP_WIDGET_BUTTON */ 89 } u; 90 /* 91 * Range uses no name - the name is implicitly the value. XXX Move name 92 * up into a struct with value. 93 */ 94 char *name; /* name matching the value */ 95 } ValueNameType; 96 97 typedef struct { 98 CameraWidgetType reg_widget_type; 99 uint32_t regs_mask; 100 char *regs_short_name; /* for command line use */ 101 char *regs_long_name; /* for gui/curses use */ 102 uint32_t reg_val_name_cnt; /* number of regs_value_names entries */ 103 ValueNameType *regs_value_names; /* list of reg value/names */ 104 } RegisterDescriptorType; 105 106 /* 107 * XXX check usage of reg_value, maybe change it to char x[8], and 108 * normally type cast its usage. 109 */ 110 typedef struct { 111 uint32_t reg_number; /* register number */ 112 uint32_t reg_len; /* size in bytes of data at register */ 113 uint64_t reg_value; /* stored value, has no valid initial value; 114 * The size would have to be increased, or 115 * this space must be allocated for 116 * register values longer than 8 bytes. */ 117 GetSetType reg_get_set; 118 uint32_t reg_desc_cnt; /* number of reg_desc entries */ 119 RegisterDescriptorType *reg_desc; /* list of reg descriptors */ 120 } CameraRegisterType; 121 122 typedef struct CameraRegisterSet { 123 char *window_name; 124 uint32_t reg_cnt; 125 CameraRegisterType *regs; 126 } CameraRegisterSetType; 127 128 typedef struct CameraDesc { 129 const CameraRegisterSetType *regset; 130 const char * const manual; 131 const SierraFlags flags; 132 } CameraDescType; 133 134 /* 135 * oly-desc.c: 136 */ 137 extern const CameraDescType sierra_default_cam_desc; 138 extern const CameraDescType olysp500uz_cam_desc; 139 extern const CameraDescType oly750uz_cam_desc; 140 extern const CameraDescType oly3040_cam_desc; 141 extern const CameraDescType oly3000z_cam_desc; 142 143 /* 144 * nikon-desc.c: 145 */ 146 extern const CameraDescType cp880_cam_desc; 147 extern const CameraDescType cp995_cam_desc; 148 extern const CameraDescType cp2500_cam_desc; 149 extern const CameraDescType cp4300_cam_desc; 150 151 /* 152 * epson-desc.c: 153 */ 154 extern const CameraDescType ep3000z_cam_desc; 155 156 #endif /* __SIERRA_DESC_H__ */ 157