Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
m5mols_core.c File Reference
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/videodev2.h>
#include <linux/module.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>
#include <media/m5mols.h>
#include "m5mols.h"
#include "m5mols_reg.h"

Go to the source code of this file.

Macros

#define MODULE_NAME   "M5MOLS"
 
#define M5MOLS_I2C_CHECK_RETRY   500
 
#define SIZE_DEFAULT_FFMT   ARRAY_SIZE(m5mols_default_ffmt)
 

Functions

 module_param (m5mols_debug, int, 0644)
 
int m5mols_read_u8 (struct v4l2_subdev *sd, u32 reg, u8 *val)
 
int m5mols_read_u16 (struct v4l2_subdev *sd, u32 reg, u16 *val)
 
int m5mols_read_u32 (struct v4l2_subdev *sd, u32 reg, u32 *val)
 
int m5mols_write (struct v4l2_subdev *sd, u32 reg, u32 val)
 
int m5mols_busy_wait (struct v4l2_subdev *sd, u32 reg, u32 value, u32 mask, int timeout)
 
int m5mols_enable_interrupt (struct v4l2_subdev *sd, u8 reg)
 
int m5mols_wait_interrupt (struct v4l2_subdev *sd, u8 irq_mask, u32 timeout)
 
int m5mols_set_mode (struct m5mols_info *info, u8 mode)
 

Variables

int m5mols_debug
 

Macro Definition Documentation

#define M5MOLS_I2C_CHECK_RETRY   500

Definition at line 37 of file m5mols_core.c.

#define MODULE_NAME   "M5MOLS"

Definition at line 36 of file m5mols_core.c.

#define SIZE_DEFAULT_FFMT   ARRAY_SIZE(m5mols_default_ffmt)

Definition at line 72 of file m5mols_core.c.

Function Documentation

int m5mols_busy_wait ( struct v4l2_subdev sd,
u32  reg,
u32  value,
u32  mask,
int  timeout 
)

m5mols_busy_wait - Busy waiting with I2C register polling : the I2C_REG() address of an 8-bit status register to check : expected status register value : bit mask for the read status register value : timeout in miliseconds, or -1 for default timeout

The register value is ORed with before comparing with .

Return: 0 if the requested condition became true within less than ms, or else negative errno.

Definition at line 296 of file m5mols_core.c.

int m5mols_enable_interrupt ( struct v4l2_subdev sd,
u8  reg 
)

m5mols_enable_interrupt - Clear interrupt pending bits and unmask interrupts

Before writing desired interrupt value the INT_FACTOR register should be read to clear pending interrupts.

Definition at line 322 of file m5mols_core.c.

int m5mols_read_u16 ( struct v4l2_subdev sd,
u32  reg,
u16 val 
)

Definition at line 205 of file m5mols_core.c.

int m5mols_read_u32 ( struct v4l2_subdev sd,
u32  reg,
u32 val 
)

Definition at line 223 of file m5mols_core.c.

int m5mols_read_u8 ( struct v4l2_subdev sd,
u32  reg,
u8 val 
)

Definition at line 187 of file m5mols_core.c.

int m5mols_set_mode ( struct m5mols_info info,
u8  mode 
)

m5mols_set_mode - set the M-5MOLS controller mode : the required operation mode

The commands of M-5MOLS are grouped into specific modes. Each functionality can be guaranteed only when the sensor is operating in mode which a command belongs to.

Definition at line 372 of file m5mols_core.c.

int m5mols_wait_interrupt ( struct v4l2_subdev sd,
u8  irq_mask,
u32  timeout 
)

Definition at line 335 of file m5mols_core.c.

int m5mols_write ( struct v4l2_subdev sd,
u32  reg,
u32  val 
)

m5mols_write - I2C command write function : combination of size, category and command for the I2C packet : value to write

Returns 0 on success, or else negative errno.

Definition at line 240 of file m5mols_core.c.

module_param ( m5mols_debug  ,
int  ,
0644   
)

Variable Documentation

int m5mols_debug

Definition at line 33 of file m5mols_core.c.