00001 #ifndef __LIVE_VIEW_H 00002 #define __LIVE_VIEW_H 00003 00004 // Note: used in modules and platform independent code. 00005 // Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values) 00006 00007 /* 00008 Protocol notes: 00009 - Unless otherwise specified, all structure values are packed in camera native (little 00010 endian) byte order 00011 - Frame buffer and palette data are in native camera formats 00012 Some documentation may be found at http://chdk.wikia.com/wiki/Frame_buffers 00013 - The frame buffer descriptions returned may not be correct depending on the 00014 camera model and various camera settings (shooting mode, digital zoom, aspect ratio) 00015 This may result in partial images, garbage in the "valid" area or incorrect position 00016 - In some cases, the requested data may not be available. If this happens, the framebuffer 00017 or palette data offset will be zero. 00018 - The frame buffer descriptions are returned regardless of whether the data is available 00019 */ 00020 // Live View protocol version 00021 #define LIVE_VIEW_VERSION_MAJOR 2 // increase only with backwards incompatible changes (and reset minor) 00022 #define LIVE_VIEW_VERSION_MINOR 1 // increase with extensions of functionality 00023 00024 /* 00025 protocol version history 00026 < 2.0 - development versions 00027 2.0 - initial release, chdk 1.1 00028 2.1 - added palette type 4 - 16 entry VUYA, 2 bit alpha 00029 */ 00030 00031 00032 // Control flags for determining which data block to transfer 00033 #define LV_TFR_VIEWPORT 0x01 00034 #define LV_TFR_BITMAP 0x04 00035 #define LV_TFR_PALETTE 0x08 00036 00037 enum lv_aspect_rato { 00038 LV_ASPECT_4_3, 00039 LV_ASPECT_16_9, 00040 }; 00041 00042 /* 00043 Framebuffer types 00044 additional values will be added if new data formats appear 00045 */ 00046 enum lv_fb_type { 00047 LV_FB_YUV8, // 8 bit per element UYVYYY, used for live view 00048 LV_FB_PAL8, // 8 bit paletted, used for bitmap overlay. Note palette data and type sent separately 00049 }; 00050 00051 /* 00052 framebuffer data description 00053 NOTE YUV pixels widths are based on the number of Y elements 00054 */ 00055 typedef struct { 00056 int fb_type; // framebuffer type - note future versions might use different structures depending on type 00057 int data_start; // offset of data from start of live view header 00058 /* 00059 buffer width in pixels 00060 data size is always buffer_width*visible_height*(buffer bpp based on type) 00061 */ 00062 int buffer_width; 00063 /* 00064 visible size in pixels 00065 describes data within the buffer which contains image data to be displayed 00066 any offsets within buffer data are added before sending, so the top left 00067 pixel is always the first first byte of data. 00068 width must always be <= buffer_width 00069 if buffer_width is > width, the additional data should be skipped 00070 visible_height also defines the number of data rows 00071 */ 00072 int visible_width; 00073 int visible_height; 00074 00075 /* 00076 margins 00077 pixels offsets needed to replicate display position on cameras screen 00078 not used for any buffer offsets 00079 */ 00080 int margin_left; 00081 int margin_top; 00082 00083 int margin_right; 00084 int margin_bot; 00085 } lv_framebuffer_desc; 00086 00087 typedef struct { 00088 // live view sub-protocol version 00089 int version_major; 00090 int version_minor; 00091 int lcd_aspect_ratio; // physical aspect ratio of LCD 00092 int palette_type; 00093 int palette_data_start; 00094 // framebuffer descriptions are given as offsets, to allow expanding the structures in minor protocol changes 00095 int vp_desc_start; 00096 int bm_desc_start; 00097 } lv_data_header; 00098 00099 #endif // __LIVE_VIEW_H