Commit 9dab501b authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] V4L: Update the saa7146 driver

 - [DVB] saa7146 driver updates:
   - remove bogus v_calc and h_calc parameters, which can be easily
     retrieved from other values
   - add class parameter to i2c initialization
   - let resource handling provide more useful informations
   - sanitize overlay/capture locking
parent 196c4ebd
...@@ -10,14 +10,14 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit) ...@@ -10,14 +10,14 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit)
struct saa7146_dev *dev = fh->dev; struct saa7146_dev *dev = fh->dev;
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
if (fh->resources & bit) if (fh->resources & bit) {
DEB_D(("already allocated! want: 0x%02x, cur:0x%02x\n",bit,vv->resources));
/* have it already allocated */ /* have it already allocated */
return 1; return 1;
}
/* is it free? */ /* is it free? */
DEB_D(("getting lock...\n"));
down(&dev->lock); down(&dev->lock);
DEB_D(("got lock\n"));
if (vv->resources & bit) { if (vv->resources & bit) {
DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit)); DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit));
/* no, someone else uses it */ /* no, someone else uses it */
...@@ -27,7 +27,7 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit) ...@@ -27,7 +27,7 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit)
/* it's free, grab it */ /* it's free, grab it */
fh->resources |= bit; fh->resources |= bit;
vv->resources |= bit; vv->resources |= bit;
DEB_D(("res: get %d\n",bit)); DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources));
up(&dev->lock); up(&dev->lock);
return 1; return 1;
} }
...@@ -51,12 +51,10 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits) ...@@ -51,12 +51,10 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
if ((fh->resources & bits) != bits) if ((fh->resources & bits) != bits)
BUG(); BUG();
DEB_D(("getting lock...\n"));
down(&dev->lock); down(&dev->lock);
DEB_D(("got lock\n"));
fh->resources &= ~bits; fh->resources &= ~bits;
vv->resources &= ~bits; vv->resources &= ~bits;
DEB_D(("res: put %d\n",bits)); DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources));
up(&dev->lock); up(&dev->lock);
} }
......
...@@ -536,13 +536,13 @@ static void saa7146_set_window(struct saa7146_dev *dev, int width, int height, e ...@@ -536,13 +536,13 @@ static void saa7146_set_window(struct saa7146_dev *dev, int width, int height, e
/* set vertical scale */ /* set vertical scale */
hps_v_scale = 0; /* all bits get set by the function-call */ hps_v_scale = 0; /* all bits get set by the function-call */
hps_v_gain = 0; /* fixme: saa7146_read(dev, HPS_V_GAIN);*/ hps_v_gain = 0; /* fixme: saa7146_read(dev, HPS_V_GAIN);*/
calculate_v_scale_registers(dev, field, vv->standard->v_calc, height, &hps_v_scale, &hps_v_gain); calculate_v_scale_registers(dev, field, vv->standard->v_field*2, height, &hps_v_scale, &hps_v_gain);
/* set horizontal scale */ /* set horizontal scale */
hps_ctrl = 0; hps_ctrl = 0;
hps_h_prescale = 0; /* all bits get set in the function */ hps_h_prescale = 0; /* all bits get set in the function */
hps_h_scale = 0; hps_h_scale = 0;
calculate_h_scale_registers(dev, vv->standard->h_calc, width, vv->hflip, &hps_ctrl, &hps_v_gain, &hps_h_prescale, &hps_h_scale); calculate_h_scale_registers(dev, vv->standard->h_pixels, width, vv->hflip, &hps_ctrl, &hps_v_gain, &hps_h_prescale, &hps_h_scale);
/* set hyo and hxo */ /* set hyo and hxo */
calculate_hxo_and_hyo(vv, &hps_h_scale, &hps_ctrl); calculate_hxo_and_hyo(vv, &hps_h_scale, &hps_ctrl);
......
...@@ -400,7 +400,7 @@ static struct i2c_algorithm saa7146_algo = { ...@@ -400,7 +400,7 @@ static struct i2c_algorithm saa7146_algo = {
.functionality = saa7146_i2c_func, .functionality = saa7146_i2c_func,
}; };
int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate) int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, unsigned int class, u32 bitrate)
{ {
DEB_EE(("bitrate: 0x%08x\n",bitrate)); DEB_EE(("bitrate: 0x%08x\n",bitrate));
...@@ -417,16 +417,13 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c ...@@ -417,16 +417,13 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c
i2c_adapter->data = dev; i2c_adapter->data = dev;
#else #else
i2c_set_adapdata(i2c_adapter,dev); i2c_set_adapdata(i2c_adapter,dev);
i2c_adapter->class = class;
#endif #endif
i2c_adapter->algo = &saa7146_algo; i2c_adapter->algo = &saa7146_algo;
i2c_adapter->algo_data = NULL; i2c_adapter->algo_data = NULL;
i2c_adapter->id = I2C_ALGO_SAA7146; i2c_adapter->id = I2C_ALGO_SAA7146;
i2c_adapter->timeout = SAA7146_I2C_TIMEOUT; i2c_adapter->timeout = SAA7146_I2C_TIMEOUT;
i2c_adapter->retries = SAA7146_I2C_RETRIES; i2c_adapter->retries = SAA7146_I2C_RETRIES;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#else
i2c_adapter->class = I2C_ADAP_CLASS_TV_ANALOG;
#endif
} }
return 0; return 0;
......
This diff is collapsed.
...@@ -154,7 +154,7 @@ struct saa7146_dev ...@@ -154,7 +154,7 @@ struct saa7146_dev
}; };
/* from saa7146_i2c.c */ /* from saa7146_i2c.c */
int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate); int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, unsigned int class, u32 bitrate);
int saa7146_i2c_transfer(struct saa7146_dev *saa, const struct i2c_msg msgs[], int num, int retries); int saa7146_i2c_transfer(struct saa7146_dev *saa, const struct i2c_msg msgs[], int num, int retries);
/* from saa7146_core.c */ /* from saa7146_core.c */
......
...@@ -44,11 +44,9 @@ struct saa7146_standard ...@@ -44,11 +44,9 @@ struct saa7146_standard
int v_offset; /* number of lines of vertical offset before processing */ int v_offset; /* number of lines of vertical offset before processing */
int v_field; /* number of lines in a field for HPS to process */ int v_field; /* number of lines in a field for HPS to process */
int v_calc; /* number of vertical active lines */
int h_offset; /* horizontal offset of processing window */ int h_offset; /* horizontal offset of processing window */
int h_pixels; /* number of horizontal pixels to process */ int h_pixels; /* number of horizontal pixels to process */
int h_calc; /* number of horizontal active pixels */
int v_max_out; int v_max_out;
int h_max_out; int h_max_out;
...@@ -104,6 +102,9 @@ struct saa7146_fh { ...@@ -104,6 +102,9 @@ struct saa7146_fh {
unsigned int resources; /* resource management for device open */ unsigned int resources; /* resource management for device open */
}; };
#define STATUS_OVERLAY 0x01
#define STATUS_CAPTURE 0x02
struct saa7146_vv struct saa7146_vv
{ {
int vbi_minor; int vbi_minor;
...@@ -117,14 +118,17 @@ struct saa7146_vv ...@@ -117,14 +118,17 @@ struct saa7146_vv
int video_minor; int video_minor;
int video_status;
struct saa7146_fh *video_fh;
/* video overlay */ /* video overlay */
struct v4l2_framebuffer ov_fb; struct v4l2_framebuffer ov_fb;
struct saa7146_format *ov_fmt; struct saa7146_format *ov_fmt;
struct saa7146_overlay *ov_data; struct saa7146_overlay *ov_data;
struct saa7146_fh *ov_suspend;
/* video capture */ /* video capture */
struct saa7146_dmaqueue video_q; struct saa7146_dmaqueue video_q;
struct saa7146_fh *streaming;
enum v4l2_field last_field; enum v4l2_field last_field;
/* common: fixme? shouldn't this be in saa7146_fh? /* common: fixme? shouldn't this be in saa7146_fh?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment