Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
v4l2-common.c File Reference
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/i2c.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <asm/div64.h>
#include <media/v4l2-common.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-chip-ident.h>
#include <linux/videodev2.h>

Go to the source code of this file.

Macros

#define CVT_PXL_CLK_GRAN   250000 /* pixel clock granularity */
 
#define CVT_MIN_V_BPORCH   7 /* lines */
 
#define CVT_MIN_V_PORCH_RND   3 /* lines */
 
#define CVT_MIN_VSYNC_BP   550 /* min time of vsync + back porch (us) */
 
#define CVT_CELL_GRAN   8 /* character cell granularity */
 
#define CVT_M   600 /* blanking formula gradient */
 
#define CVT_C   40 /* blanking formula offset */
 
#define CVT_K   128 /* blanking formula scaling factor */
 
#define CVT_J   20 /* blanking formula scaling factor */
 
#define CVT_C_PRIME   (((CVT_C - CVT_J) * CVT_K / 256) + CVT_J)
 
#define CVT_M_PRIME   (CVT_K * CVT_M / 256)
 
#define CVT_RB_MIN_V_BPORCH   7 /* lines */
 
#define CVT_RB_V_FPORCH   3 /* lines */
 
#define CVT_RB_MIN_V_BLANK   460 /* us */
 
#define CVT_RB_H_SYNC   32 /* pixels */
 
#define CVT_RB_H_BPORCH   80 /* pixels */
 
#define CVT_RB_H_BLANK   160 /* pixels */
 
#define GTF_PXL_CLK_GRAN   250000 /* pixel clock granularity */
 
#define GTF_MIN_VSYNC_BP   550 /* min time of vsync + back porch (us) */
 
#define GTF_V_FP   1 /* vertical front porch (lines) */
 
#define GTF_CELL_GRAN   8 /* character cell granularity */
 
#define GTF_D_M   600 /* blanking formula gradient */
 
#define GTF_D_C   40 /* blanking formula offset */
 
#define GTF_D_K   128 /* blanking formula scaling factor */
 
#define GTF_D_J   20 /* blanking formula scaling factor */
 
#define GTF_D_C_PRIME   ((((GTF_D_C - GTF_D_J) * GTF_D_K) / 256) + GTF_D_J)
 
#define GTF_D_M_PRIME   ((GTF_D_K * GTF_D_M) / 256)
 
#define GTF_S_M   3600 /* blanking formula gradient */
 
#define GTF_S_C   40 /* blanking formula offset */
 
#define GTF_S_K   128 /* blanking formula scaling factor */
 
#define GTF_S_J   35 /* blanking formula scaling factor */
 
#define GTF_S_C_PRIME   ((((GTF_S_C - GTF_S_J) * GTF_S_K) / 256) + GTF_S_J)
 
#define GTF_S_M_PRIME   ((GTF_S_K * GTF_S_M) / 256)
 

Functions

 MODULE_AUTHOR ("Bill Dirks, Justin Schoeman, Gerd Knorr")
 
 MODULE_DESCRIPTION ("misc helper functions for v4l2 device drivers")
 
 MODULE_LICENSE ("GPL")
 
int v4l2_ctrl_check (struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, const char *const *menu_items)
 
 EXPORT_SYMBOL (v4l2_ctrl_check)
 
int v4l2_ctrl_query_fill (struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def)
 
 EXPORT_SYMBOL (v4l2_ctrl_query_fill)
 
int v4l2_ctrl_query_menu (struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qctrl, const char *const *menu_items)
 
 EXPORT_SYMBOL (v4l2_ctrl_query_menu)
 
int v4l2_ctrl_query_menu_valid_items (struct v4l2_querymenu *qmenu, const u32 *ids)
 
 EXPORT_SYMBOL (v4l2_ctrl_query_menu_valid_items)
 
u32 v4l2_ctrl_next (const u32 *const *ctrl_classes, u32 id)
 
 EXPORT_SYMBOL (v4l2_ctrl_next)
 
int v4l2_chip_match_host (const struct v4l2_dbg_match *match)
 
 EXPORT_SYMBOL (v4l2_chip_match_host)
 
void v4l_bound_align_image (u32 *w, unsigned int wmin, unsigned int wmax, unsigned int walign, u32 *h, unsigned int hmin, unsigned int hmax, unsigned int halign, unsigned int salign)
 
 EXPORT_SYMBOL_GPL (v4l_bound_align_image)
 
int v4l_fill_dv_preset_info (u32 preset, struct v4l2_dv_enum_preset *info)
 
 EXPORT_SYMBOL_GPL (v4l_fill_dv_preset_info)
 
bool v4l_match_dv_timings (const struct v4l2_dv_timings *t1, const struct v4l2_dv_timings *t2, unsigned pclock_delta)
 
 EXPORT_SYMBOL_GPL (v4l_match_dv_timings)
 
bool v4l2_detect_cvt (unsigned frame_height, unsigned hfreq, unsigned vsync, u32 polarities, struct v4l2_dv_timings *fmt)
 
 EXPORT_SYMBOL_GPL (v4l2_detect_cvt)
 
bool v4l2_detect_gtf (unsigned frame_height, unsigned hfreq, unsigned vsync, u32 polarities, struct v4l2_fract aspect, struct v4l2_dv_timings *fmt)
 
 EXPORT_SYMBOL_GPL (v4l2_detect_gtf)
 
struct v4l2_fract v4l2_calc_aspect_ratio (u8 hor_landscape, u8 vert_portrait)
 
 EXPORT_SYMBOL_GPL (v4l2_calc_aspect_ratio)
 
struct v4l2_frmsize_discretev4l2_find_nearest_format (const struct v4l2_discrete_probe *probe, s32 width, s32 height)
 
 EXPORT_SYMBOL_GPL (v4l2_find_nearest_format)
 

Macro Definition Documentation

#define CVT_C   40 /* blanking formula offset */

Definition at line 649 of file v4l2-common.c.

#define CVT_C_PRIME   (((CVT_C - CVT_J) * CVT_K / 256) + CVT_J)

Definition at line 652 of file v4l2-common.c.

#define CVT_CELL_GRAN   8 /* character cell granularity */

Definition at line 647 of file v4l2-common.c.

#define CVT_J   20 /* blanking formula scaling factor */

Definition at line 651 of file v4l2-common.c.

#define CVT_K   128 /* blanking formula scaling factor */

Definition at line 650 of file v4l2-common.c.

#define CVT_M   600 /* blanking formula gradient */

Definition at line 648 of file v4l2-common.c.

#define CVT_M_PRIME   (CVT_K * CVT_M / 256)

Definition at line 653 of file v4l2-common.c.

#define CVT_MIN_V_BPORCH   7 /* lines */

Definition at line 642 of file v4l2-common.c.

#define CVT_MIN_V_PORCH_RND   3 /* lines */

Definition at line 643 of file v4l2-common.c.

#define CVT_MIN_VSYNC_BP   550 /* min time of vsync + back porch (us) */

Definition at line 644 of file v4l2-common.c.

#define CVT_PXL_CLK_GRAN   250000 /* pixel clock granularity */

Definition at line 639 of file v4l2-common.c.

#define CVT_RB_H_BLANK   160 /* pixels */

Definition at line 661 of file v4l2-common.c.

#define CVT_RB_H_BPORCH   80 /* pixels */

Definition at line 660 of file v4l2-common.c.

#define CVT_RB_H_SYNC   32 /* pixels */

Definition at line 659 of file v4l2-common.c.

#define CVT_RB_MIN_V_BLANK   460 /* us */

Definition at line 658 of file v4l2-common.c.

#define CVT_RB_MIN_V_BPORCH   7 /* lines */

Definition at line 656 of file v4l2-common.c.

#define CVT_RB_V_FPORCH   3 /* lines */

Definition at line 657 of file v4l2-common.c.

#define GTF_CELL_GRAN   8 /* character cell granularity */

Definition at line 797 of file v4l2-common.c.

#define GTF_D_C   40 /* blanking formula offset */

Definition at line 801 of file v4l2-common.c.

#define GTF_D_C_PRIME   ((((GTF_D_C - GTF_D_J) * GTF_D_K) / 256) + GTF_D_J)

Definition at line 804 of file v4l2-common.c.

#define GTF_D_J   20 /* blanking formula scaling factor */

Definition at line 803 of file v4l2-common.c.

#define GTF_D_K   128 /* blanking formula scaling factor */

Definition at line 802 of file v4l2-common.c.

#define GTF_D_M   600 /* blanking formula gradient */

Definition at line 800 of file v4l2-common.c.

#define GTF_D_M_PRIME   ((GTF_D_K * GTF_D_M) / 256)

Definition at line 805 of file v4l2-common.c.

#define GTF_MIN_VSYNC_BP   550 /* min time of vsync + back porch (us) */

Definition at line 795 of file v4l2-common.c.

#define GTF_PXL_CLK_GRAN   250000 /* pixel clock granularity */

Definition at line 793 of file v4l2-common.c.

#define GTF_S_C   40 /* blanking formula offset */

Definition at line 809 of file v4l2-common.c.

#define GTF_S_C_PRIME   ((((GTF_S_C - GTF_S_J) * GTF_S_K) / 256) + GTF_S_J)

Definition at line 812 of file v4l2-common.c.

#define GTF_S_J   35 /* blanking formula scaling factor */

Definition at line 811 of file v4l2-common.c.

#define GTF_S_K   128 /* blanking formula scaling factor */

Definition at line 810 of file v4l2-common.c.

#define GTF_S_M   3600 /* blanking formula gradient */

Definition at line 808 of file v4l2-common.c.

#define GTF_S_M_PRIME   ((GTF_S_K * GTF_S_M) / 256)

Definition at line 813 of file v4l2-common.c.

#define GTF_V_FP   1 /* vertical front porch (lines) */

Definition at line 796 of file v4l2-common.c.

Function Documentation

EXPORT_SYMBOL ( v4l2_ctrl_check  )
EXPORT_SYMBOL ( v4l2_ctrl_query_fill  )
EXPORT_SYMBOL ( v4l2_ctrl_query_menu  )
EXPORT_SYMBOL ( v4l2_ctrl_query_menu_valid_items  )
EXPORT_SYMBOL ( v4l2_ctrl_next  )
EXPORT_SYMBOL ( v4l2_chip_match_host  )
EXPORT_SYMBOL_GPL ( v4l_bound_align_image  )
EXPORT_SYMBOL_GPL ( v4l_fill_dv_preset_info  )
EXPORT_SYMBOL_GPL ( v4l_match_dv_timings  )
EXPORT_SYMBOL_GPL ( v4l2_detect_cvt  )
EXPORT_SYMBOL_GPL ( v4l2_detect_gtf  )
EXPORT_SYMBOL_GPL ( v4l2_calc_aspect_ratio  )
EXPORT_SYMBOL_GPL ( v4l2_find_nearest_format  )
MODULE_AUTHOR ( "Bill  Dirks,
Justin  Schoeman,
Gerd Knorr"   
)
MODULE_DESCRIPTION ( "misc helper functions for v4l2 device drivers"  )
MODULE_LICENSE ( "GPL"  )
struct v4l2_fract v4l2_calc_aspect_ratio ( u8  hor_landscape,
u8  vert_portrait 
)
read

v4l2_calc_aspect_ratio - calculate the aspect ratio based on bytes 0x15 and 0x16 from the EDID. - byte 0x15 from the EDID. - byte 0x16 from the EDID.

Determines the aspect ratio from the EDID. See VESA Enhanced EDID standard, release A, rev 2, section 3.6.2: "Horizontal and Vertical Screen Size or Aspect Ratio"

Definition at line 916 of file v4l2-common.c.

int v4l2_chip_match_host ( const struct v4l2_dbg_match match)

Definition at line 230 of file v4l2-common.c.

int v4l2_ctrl_check ( struct v4l2_ext_control ctrl,
struct v4l2_queryctrl qctrl,
const char *const menu_items 
)

Definition at line 87 of file v4l2-common.c.

u32 v4l2_ctrl_next ( const u32 *const ctrl_classes,
u32  id 
)

Definition at line 187 of file v4l2-common.c.

int v4l2_ctrl_query_fill ( struct v4l2_queryctrl qctrl,
s32  min,
s32  max,
s32  step,
s32  def 
)

Definition at line 115 of file v4l2-common.c.

int v4l2_ctrl_query_menu ( struct v4l2_querymenu qmenu,
struct v4l2_queryctrl qctrl,
const char *const menu_items 
)

Definition at line 139 of file v4l2-common.c.

int v4l2_ctrl_query_menu_valid_items ( struct v4l2_querymenu qmenu,
const u32 ids 
)

Definition at line 161 of file v4l2-common.c.

bool v4l2_detect_cvt ( unsigned  frame_height,
unsigned  hfreq,
unsigned  vsync,
u32  polarities,
struct v4l2_dv_timings fmt 
)

v4l2_detect_cvt - detect if the given timings follow the CVT standard - the total height of the frame (including blanking) in lines. - the horizontal frequency in Hz. - the height of the vertical sync in lines. - the horizontal and vertical polarities (same as struct v4l2_bt_timings polarities). - the resulting timings.

This function will attempt to detect if the given values correspond to a valid CVT format. If so, then it will return true, and fmt will be filled in with the found CVT timings.

Definition at line 675 of file v4l2-common.c.

bool v4l2_detect_gtf ( unsigned  frame_height,
unsigned  hfreq,
unsigned  vsync,
u32  polarities,
struct v4l2_fract  aspect,
struct v4l2_dv_timings fmt 
)

v4l2_detect_gtf - detect if the given timings follow the GTF standard - the total height of the frame (including blanking) in lines. - the horizontal frequency in Hz. - the height of the vertical sync in lines. - the horizontal and vertical polarities (same as struct v4l2_bt_timings polarities). - preferred aspect ratio. GTF has no method of determining the aspect ratio in order to derive the image width from the image height, so it has to be passed explicitly. Usually the native screen aspect ratio is used for this. If it is not filled in correctly, then 16:9 will be assumed. - the resulting timings.

This function will attempt to detect if the given values correspond to a valid GTF format. If so, then it will return true, and fmt will be filled in with the found GTF timings.

Definition at line 832 of file v4l2-common.c.

struct v4l2_frmsize_discrete* v4l2_find_nearest_format ( const struct v4l2_discrete_probe probe,
s32  width,
s32  height 
)
read

Definition at line 958 of file v4l2-common.c.

void v4l_bound_align_image ( u32 w,
unsigned int  wmin,
unsigned int  wmax,
unsigned int  walign,
u32 h,
unsigned int  hmin,
unsigned int  hmax,
unsigned int  halign,
unsigned int  salign 
)

Definition at line 516 of file v4l2-common.c.

int v4l_fill_dv_preset_info ( u32  preset,
struct v4l2_dv_enum_preset info 
)

v4l_fill_dv_preset_info - fill description of a digital video preset - preset value - pointer to struct v4l2_dv_enum_preset

drivers can use this helper function to fill description of dv preset in info.

Definition at line 561 of file v4l2-common.c.

bool v4l_match_dv_timings ( const struct v4l2_dv_timings t1,
const struct v4l2_dv_timings t2,
unsigned  pclock_delta 
)

v4l_match_dv_timings - check if two timings match - compare this v4l2_dv_timings struct... - with this struct. - the allowed pixelclock deviation.

Compare t1 with t2 with a given margin of error for the pixelclock.

Definition at line 608 of file v4l2-common.c.