1 #ifndef __LIVE_VIEW_H 2 #define __LIVE_VIEW_H 3 4 // Note: used in modules and platform independent code. 5 // Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values) 6 7 /* 8 Protocol notes: 9 - Unless otherwise specified, all structure values are packed in camera native (little 10 endian) byte order 11 - Frame buffer and palette data are in native camera formats 12 Some documentation may be found at http://chdk.wikia.com/wiki/Frame_buffers 13 - The frame buffer descriptions returned may not be correct depending on the 14 camera model and various camera settings (shooting mode, digital zoom, aspect ratio) 15 This may result in partial images, garbage in the "valid" area or incorrect position 16 - In some cases, the requested data may not be available. If this happens, the framebuffer 17 or palette data offset will be zero. 18 - The frame buffer descriptions are returned regardless of whether the data is available 19 */ 20 // Live View protocol version 21 #define LIVE_VIEW_VERSION_MAJOR 2 // increase only with backwards incompatible changes (and reset minor) 22 #define LIVE_VIEW_VERSION_MINOR 1 // increase with extensions of functionality 23 24 /* 25 protocol version history 26 < 2.0 - development versions 27 2.0 - initial release, chdk 1.1 28 2.1 - added palette type 4 - 16 entry VUYA, 2 bit alpha 29 */ 30 31 32 // Control flags for determining which data block to transfer 33 #define LV_TFR_VIEWPORT 0x01 34 #define LV_TFR_BITMAP 0x04 35 #define LV_TFR_PALETTE 0x08 36 37 enum lv_aspect_rato { 38 LV_ASPECT_4_3, 39 LV_ASPECT_16_9, 40 }; 41 42 /* 43 Framebuffer types 44 additional values will be added if new data formats appear 45 */ 46 enum lv_fb_type { 47 LV_FB_YUV8, // 8 bit per element UYVYYY, used for live view 48 LV_FB_PAL8, // 8 bit paletted, used for bitmap overlay. Note palette data and type sent separately 49 }; 50 51 /* 52 framebuffer data description 53 NOTE YUV pixels widths are based on the number of Y elements 54 */ 55 typedef struct { 56 int fb_type; // framebuffer type - note future versions might use different structures depending on type 57 int data_start; // offset of data from start of live view header 58 /* 59 buffer width in pixels 60 data size is always buffer_width*visible_height*(buffer bpp based on type) 61 */ 62 int buffer_width; 63 /* 64 visible size in pixels 65 describes data within the buffer which contains image data to be displayed 66 any offsets within buffer data are added before sending, so the top left 67 pixel is always the first first byte of data. 68 width must always be <= buffer_width 69 if buffer_width is > width, the additional data should be skipped 70 visible_height also defines the number of data rows 71 */ 72 int visible_width; 73 int visible_height; 74 75 /* 76 margins 77 pixels offsets needed to replicate display position on cameras screen 78 not used for any buffer offsets 79 */ 80 int margin_left; 81 int margin_top; 82 83 int margin_right; 84 int margin_bot; 85 } lv_framebuffer_desc; 86 87 typedef struct { 88 // live view sub-protocol version 89 int version_major; 90 int version_minor; 91 int lcd_aspect_ratio; // physical aspect ratio of LCD 92 int palette_type; 93 int palette_data_start; 94 // framebuffer descriptions are given as offsets, to allow expanding the structures in minor protocol changes 95 int vp_desc_start; 96 int bm_desc_start; 97 } lv_data_header; 98 99 #endif // __LIVE_VIEW_H 100