Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a731a32 authored by Jean-François Moine's avatar Jean-François Moine Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB: gspca - JPEG subdrivers: Don't allocate the JPEG header



The JPEG header is now included in the subdriver structure instead
of being allocated and freed at capture start and stop.

Signed-off-by: default avatarJean-François Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 456c9acb
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ struct sd {
#define QUALITY_MAX 60
#define QUALITY_DEF 40

	u8 *jpeg_hdr;
	u8 jpeg_hdr[JPEG_HDR_SZ];
};

/* V4L2 controls supported by the driver */
@@ -845,9 +845,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
	struct sd *sd = (struct sd *) gspca_dev;

	/* create the JPEG header */
	sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
	if (!sd->jpeg_hdr)
		return -ENOMEM;
	jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
			0x22);		/* JPEG 411 */
	jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -862,11 +859,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
/* called on streamoff with alt 0 and on disconnect */
static void sd_stop0(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;
	int retry = 50;

	kfree(sd->jpeg_hdr);

	if (!gspca_dev->present)
		return;
	reg_w_val(gspca_dev, 0x0000, 0x00);
+1 −5
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ struct sd {
	struct workqueue_struct *work_thread;
	u8 quality;				 /* image quality */
	u8 jpegqual;				/* webcam quality */
	u8 *jpeg_hdr;
	u8 jpeg_hdr[JPEG_HDR_SZ];
};

	struct jlj_command {
@@ -282,7 +282,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
	destroy_workqueue(dev->work_thread);
	dev->work_thread = NULL;
	mutex_lock(&gspca_dev->usb_lock);
	kfree(dev->jpeg_hdr);
}

/* this function is called at probe and resume time */
@@ -298,9 +297,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
	int ret;

	/* create the JPEG header */
	dev->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
	if (dev->jpeg_hdr == NULL)
		return -ENOMEM;
	jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width,
			0x21);          /* JPEG 422 */
	jpeg_set_qual(dev->jpeg_hdr, dev->quality);
+1 −12
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ struct sd {
#define QUALITY_MAX 70
#define QUALITY_DEF 50

	u8 *jpeg_hdr;
	u8 jpeg_hdr[JPEG_HDR_SZ];
};

/* V4L2 controls supported by the driver */
@@ -200,9 +200,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
	int i;

	/* create the JPEG header */
	sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
	if (!sd->jpeg_hdr)
		return -ENOMEM;
	jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
			0x21);		/* JPEG 422 */
	jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -317,13 +314,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
		PDEBUG(D_ERR, "Camera Stop failed");
}

static void sd_stop0(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;

	kfree(sd->jpeg_hdr);
}

static void sd_pkt_scan(struct gspca_dev *gspca_dev,
			u8 *data,			/* isoc packet */
			int len)			/* iso packet length */
@@ -486,7 +476,6 @@ static const struct sd_desc sd_desc = {
	.init = sd_init,
	.start = sd_start,
	.stopN = sd_stopN,
	.stop0 = sd_stop0,
	.pkt_scan = sd_pkt_scan,
	.get_jcomp = sd_get_jcomp,
	.set_jcomp = sd_set_jcomp,
+6 −1
Original line number Diff line number Diff line
@@ -41,6 +41,11 @@
#include <linux/input.h>
#include "gspca.h"

/* The jpeg_hdr is used by w996Xcf only */
/* The CONEX_CAM define for jpeg.h needs renaming, now its used here too */
#define CONEX_CAM
#include "jpeg.h"

MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
MODULE_DESCRIPTION("OV519 USB Camera Driver");
MODULE_LICENSE("GPL");
@@ -116,7 +121,7 @@ struct sd {
	int sensor_height;
	int sensor_reg_cache[256];

	u8 *jpeg_hdr;
	u8 jpeg_hdr[JPEG_HDR_SZ];
};

/* Note this is a bit of a hack, but the w9968cf driver needs the code for all
+3 −14
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ struct sd {
	u8 hstart;
	u8 vstart;

	u8 *jpeg_hdr;
	u8 jpeg_hdr[JPEG_HDR_SZ];
	u8 quality;

	u8 flags;
@@ -2162,10 +2162,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
	int height = gspca_dev->height;
	u8 fmt, scale = 0;

	sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
	if (sd->jpeg_hdr == NULL)
		return -ENOMEM;

	jpeg_define(sd->jpeg_hdr, height, width,
			0x21);
	jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -2197,8 +2193,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
	}

	configure_sensor_output(gspca_dev, mode);
	reg_w(gspca_dev, 0x1100, sd->jpeg_hdr + JPEG_QT0_OFFSET, 64);
	reg_w(gspca_dev, 0x1140, sd->jpeg_hdr + JPEG_QT1_OFFSET, 64);
	reg_w(gspca_dev, 0x1100, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64);
	reg_w(gspca_dev, 0x1140, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64);
	reg_w(gspca_dev, 0x10fb, CLR_WIN(width, height), 5);
	reg_w(gspca_dev, 0x1180, HW_WIN(mode, sd->hstart, sd->vstart), 6);
	reg_w1(gspca_dev, 0x1189, scale);
@@ -2226,12 +2222,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
	reg_w1(gspca_dev, 0x1061, gspca_dev->usb_buf[0] & ~0x02);
}

static void sd_stop0(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;
	kfree(sd->jpeg_hdr);
}

static void do_autoexposure(struct gspca_dev *gspca_dev, u16 avg_lum)
{
	struct sd *sd = (struct sd *) gspca_dev;
@@ -2397,7 +2387,6 @@ static const struct sd_desc sd_desc = {
	.init = sd_init,
	.start = sd_start,
	.stopN = sd_stopN,
	.stop0 = sd_stop0,
	.pkt_scan = sd_pkt_scan,
#ifdef CONFIG_INPUT
	.int_pkt_scan = sd_int_pkt_scan,
Loading