Re: [PATCH] Adding helper function to get dv preset description
On Thursday 19 November 2009 17:09:47 m-kariche...@ti.com wrote: From: Muralidharan Karicheri m-kariche...@ti.com This patch add a helper function to get description of a digital video preset added by the video timing API. Hope this will be usefull for drivers implementing the above API. Signed-off-by: Muralidharan Karicheri m-kariche...@ti.com NOTE: depends on the patch that adds video timing API. This is very inefficient memory-wise. struct v4l2_dv_enum_preset takes 52 bytes and since I expect that we will see a lot of presets in the future, this can add up very quickly. IMHO it is better to make a separate struct: struct v4l2_dv_preset_info { u16 width; u16 height; const char *name; }; static const struct v4l2_dv_preset_info dv_presets[] = { {0,0, Invalid }, /* V4L2_DV_INVALID */ { 720, 480, 4...@59.94 }, /* V4L2_DV_480P59_94 */ }; This is a lot more compact, especially with the strings. --- Applies to V4L-DVB linux-next branch drivers/media/video/v4l2-common.c | 135 + include/media/v4l2-common.h | 1 + 2 files changed, 136 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index f5a93ae..245e727 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -1015,3 +1015,138 @@ void v4l_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax, } } EXPORT_SYMBOL_GPL(v4l_bound_align_image); + +/** + * v4l_fill_dv_preset_info - fill description of a digital video preset + * @preset - preset value + * @info - pointer to struct v4l2_dv_enum_preset + * + * drivers can use this helper function to fill description of dv preset + * in info. + */ +int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) +{ + static const struct v4l2_dv_enum_preset dv_presets[] = { + { + .preset = V4L2_DV_480P59_94, + .name = 4...@59.94, + .width = 720, + .height = 480, + }, + { + .preset = V4L2_DV_576P50, + .name = 5...@50, + .width = 720, + .height = 576, + }, + { + .preset = V4L2_DV_720P24, + .name = 7...@24, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P25, + .name = 7...@25, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P30, + .name = 7...@30, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P50, + .name = 7...@50, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P59_94, + .name = 7...@59.94, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P60, + .name = 7...@60, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_1080I29_97, + .name = 10...@29.97, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I30, + .name = 10...@30, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I25, + .name = 10...@25, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I50, + .name = 10...@50, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I60, + .name = 10...@60, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080P24, + .name = 10...@24, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080P25, + .name = 10...@25, + .width = 1920, + .height = 1080, + }, +
[PATCH] Adding helper function to get dv preset description
From: Muralidharan Karicheri m-kariche...@ti.com This patch add a helper function to get description of a digital video preset added by the video timing API. Hope this will be usefull for drivers implementing the above API. Signed-off-by: Muralidharan Karicheri m-kariche...@ti.com NOTE: depends on the patch that adds video timing API. --- Applies to V4L-DVB linux-next branch drivers/media/video/v4l2-common.c | 135 + include/media/v4l2-common.h |1 + 2 files changed, 136 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index f5a93ae..245e727 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -1015,3 +1015,138 @@ void v4l_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax, } } EXPORT_SYMBOL_GPL(v4l_bound_align_image); + +/** + * v4l_fill_dv_preset_info - fill description of a digital video preset + * @preset - preset value + * @info - pointer to struct v4l2_dv_enum_preset + * + * drivers can use this helper function to fill description of dv preset + * in info. + */ +int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info) +{ + static const struct v4l2_dv_enum_preset dv_presets[] = { + { + .preset = V4L2_DV_480P59_94, + .name = 4...@59.94, + .width = 720, + .height = 480, + }, + { + .preset = V4L2_DV_576P50, + .name = 5...@50, + .width = 720, + .height = 576, + }, + { + .preset = V4L2_DV_720P24, + .name = 7...@24, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P25, + .name = 7...@25, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P30, + .name = 7...@30, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P50, + .name = 7...@50, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P59_94, + .name = 7...@59.94, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_720P60, + .name = 7...@60, + .width = 1280, + .height = 720, + }, + { + .preset = V4L2_DV_1080I29_97, + .name = 10...@29.97, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I30, + .name = 10...@30, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I25, + .name = 10...@25, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I50, + .name = 10...@50, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080I60, + .name = 10...@60, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080P24, + .name = 10...@24, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080P25, + .name = 10...@25, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080P30, + .name = 10...@30, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080P50, + .name = 10...@50, + .width = 1920, + .height = 1080, + }, + { + .preset = V4L2_DV_1080P60, + .name = 10...@60, + .width = 1920, +