Internal image allocation API changes

Creating by dimensions is likely not useful now that we can infer image
size from a device in question.
This commit is contained in:
Daniel Drake 2007-10-27 18:10:06 +01:00
parent 351ccb4ab7
commit 3bbb7b8b51
3 changed files with 13 additions and 10 deletions

View file

@ -142,6 +142,9 @@ extern struct fp_img_driver uru4000_driver;
void fpi_img_driver_setup(struct fp_img_driver *idriver); void fpi_img_driver_setup(struct fp_img_driver *idriver);
#define fpi_driver_to_img_driver(drv) \
container_of((drv), struct fp_img_driver, driver)
struct fp_dscv_dev { struct fp_dscv_dev {
struct usb_device *udev; struct usb_device *udev;
struct fp_driver *drv; struct fp_driver *drv;
@ -171,7 +174,7 @@ struct fp_img {
}; };
struct fp_img *fpi_img_new(size_t length); struct fp_img *fpi_img_new(size_t length);
struct fp_img *fpi_img_new_dims(int width, int height); struct fp_img *fpi_img_new_for_imgdev(struct fp_img_dev *dev);
struct fp_img *fpi_img_resize(struct fp_img *img, size_t newsize); struct fp_img *fpi_img_resize(struct fp_img *img, size_t newsize);
gboolean fpi_img_is_sane(struct fp_img *img); gboolean fpi_img_is_sane(struct fp_img *img);

View file

@ -35,8 +35,11 @@ struct fp_img *fpi_img_new(size_t length)
return img; return img;
} }
struct fp_img *fpi_img_new_dims(int width, int height) struct fp_img *fpi_img_new_for_imgdev(struct fp_img_dev *imgdev)
{ {
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(imgdev->dev->drv);
int width = imgdrv->img_width;
int height = imgdrv->img_height;
struct fp_img *img = fpi_img_new(width * height); struct fp_img *img = fpi_img_new(width * height);
img->width = width; img->width = width;
img->height = height; img->height = height;

View file

@ -22,13 +22,10 @@
#include "fp_internal.h" #include "fp_internal.h"
#define driver_to_img_driver(drv) \
container_of((drv), struct fp_img_driver, driver)
static int img_dev_init(struct fp_dev *dev, unsigned long driver_data) static int img_dev_init(struct fp_dev *dev, unsigned long driver_data)
{ {
struct fp_img_dev *imgdev = g_malloc0(sizeof(*imgdev)); struct fp_img_dev *imgdev = g_malloc0(sizeof(*imgdev));
struct fp_img_driver *imgdrv = driver_to_img_driver(dev->drv); struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(dev->drv);
int r = 0; int r = 0;
imgdev->dev = dev; imgdev->dev = dev;
@ -53,7 +50,7 @@ err:
static void img_dev_exit(struct fp_dev *dev) static void img_dev_exit(struct fp_dev *dev)
{ {
struct fp_img_dev *imgdev = dev->priv; struct fp_img_dev *imgdev = dev->priv;
struct fp_img_driver *imgdrv = driver_to_img_driver(dev->drv); struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(dev->drv);
if (imgdrv->exit) if (imgdrv->exit)
imgdrv->exit(imgdev); imgdrv->exit(imgdev);
@ -64,14 +61,14 @@ static void img_dev_exit(struct fp_dev *dev)
API_EXPORTED int fp_imgdev_get_img_width(struct fp_img_dev *imgdev) API_EXPORTED int fp_imgdev_get_img_width(struct fp_img_dev *imgdev)
{ {
struct fp_driver *drv = imgdev->dev->drv; struct fp_driver *drv = imgdev->dev->drv;
struct fp_img_driver *imgdrv = driver_to_img_driver(drv); struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
return imgdrv->img_width; return imgdrv->img_width;
} }
API_EXPORTED int fp_imgdev_get_img_height(struct fp_img_dev *imgdev) API_EXPORTED int fp_imgdev_get_img_height(struct fp_img_dev *imgdev)
{ {
struct fp_driver *drv = imgdev->dev->drv; struct fp_driver *drv = imgdev->dev->drv;
struct fp_img_driver *imgdrv = driver_to_img_driver(drv); struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
return imgdrv->img_height; return imgdrv->img_height;
} }
@ -79,7 +76,7 @@ API_EXPORTED int fp_imgdev_capture(struct fp_img_dev *imgdev,
int unconditional, struct fp_img **image) int unconditional, struct fp_img **image)
{ {
struct fp_driver *drv = imgdev->dev->drv; struct fp_driver *drv = imgdev->dev->drv;
struct fp_img_driver *imgdrv = driver_to_img_driver(drv); struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
int r; int r;
if (!image) { if (!image) {