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

Commit dc8a7e83 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab
Browse files

[media] pwc: Remove dead snapshot code



The in kernel version of the pwc driver has never supported snapshot
mode, and now that we no longer support the pixfmt.priv abuse there also
no longer is a way for userspace to request it, rendering all the code in
question dead (never called), so remove it.

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 115f418b
Loading
Loading
Loading
Loading
+22 −42
Original line number Original line Diff line number Diff line
@@ -220,7 +220,6 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames)


	/* Set various parameters */
	/* Set various parameters */
	pdev->vframes = frames;
	pdev->vframes = frames;
	pdev->vsize = size;
	pdev->valternate = pEntry->alternate;
	pdev->valternate = pEntry->alternate;
	pdev->image = pwc_image_sizes[size];
	pdev->image = pwc_image_sizes[size];
	pdev->frame_size = (pdev->image.x * pdev->image.y * 3) / 2;
	pdev->frame_size = (pdev->image.x * pdev->image.y * 3) / 2;
@@ -240,7 +239,8 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames)
}
}




static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, int compression, int snapshot)
static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames,
	int compression)
{
{
	unsigned char buf[13];
	unsigned char buf[13];
	const struct Timon_table_entry *pChoose;
	const struct Timon_table_entry *pChoose;
@@ -266,8 +266,6 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i
		return -ENOENT; /* Not supported. */
		return -ENOENT; /* Not supported. */


	memcpy(buf, pChoose->mode, 13);
	memcpy(buf, pChoose->mode, 13);
	if (snapshot)
		buf[0] |= 0x80;
	ret = send_video_command(pdev, pdev->vendpoint, buf, 13);
	ret = send_video_command(pdev, pdev->vendpoint, buf, 13);
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;
@@ -283,8 +281,6 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i


	/* Set various parameters */
	/* Set various parameters */
	pdev->vframes = frames;
	pdev->vframes = frames;
	pdev->vsize = size;
	pdev->vsnapshot = snapshot;
	pdev->valternate = pChoose->alternate;
	pdev->valternate = pChoose->alternate;
	pdev->image = pwc_image_sizes[size];
	pdev->image = pwc_image_sizes[size];
	pdev->vbandlength = pChoose->bandlength;
	pdev->vbandlength = pChoose->bandlength;
@@ -296,12 +292,12 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i
}
}




static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, int compression, int snapshot)
static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames,
	int compression)
{
{
	const struct Kiara_table_entry *pChoose = NULL;
	const struct Kiara_table_entry *pChoose = NULL;
	int fps, ret;
	int fps, ret;
	unsigned char buf[12];
	unsigned char buf[12];
	struct Kiara_table_entry RawEntry = {6, 773, 1272, {0xAD, 0xF4, 0x10, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}};


	if (size >= PSZ_MAX || frames < 5 || frames > 30 || compression < 0 || compression > 3)
	if (size >= PSZ_MAX || frames < 5 || frames > 30 || compression < 0 || compression > 3)
		return -EINVAL;
		return -EINVAL;
@@ -309,30 +305,16 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
		return -EINVAL;
		return -EINVAL;
	fps = (frames / 5) - 1;
	fps = (frames / 5) - 1;


	/* special case: VGA @ 5 fps and snapshot is raw bayer mode */
	/* Find a supported framerate with progressively higher compression
	if (size == PSZ_VGA && frames == 5 && snapshot && pdev->pixfmt != V4L2_PIX_FMT_YUV420)
	   ratios if the preferred ratio is not available.
	{
		/* Only available in case the raw palette is selected or
		   we have the decompressor available. This mode is
		   only available in compressed form
		*/
		PWC_DEBUG_SIZE("Choosing VGA/5 BAYER mode.\n");
		pChoose = &RawEntry;
	}
	else
	{
		/* Find a supported framerate with progressively higher compression ratios
		   if the preferred ratio is not available.
	   Skip this step when using RAW modes.
	   Skip this step when using RAW modes.
	*/
	*/
		snapshot = 0;
	while (compression <= 3) {
	while (compression <= 3) {
		pChoose = &Kiara_table[size][fps][compression];
		pChoose = &Kiara_table[size][fps][compression];
		if (pChoose->alternate != 0)
		if (pChoose->alternate != 0)
			break;
			break;
		compression++;
		compression++;
	}
	}
	}
	if (pChoose == NULL || pChoose->alternate == 0)
	if (pChoose == NULL || pChoose->alternate == 0)
		return -ENOENT; /* Not supported. */
		return -ENOENT; /* Not supported. */


@@ -340,8 +322,6 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i


	/* usb_control_msg won't take staticly allocated arrays as argument?? */
	/* usb_control_msg won't take staticly allocated arrays as argument?? */
	memcpy(buf, pChoose->mode, 12);
	memcpy(buf, pChoose->mode, 12);
	if (snapshot)
		buf[0] |= 0x80;


	/* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */
	/* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */
	ret = send_video_command(pdev, 4 /* pdev->vendpoint */, buf, 12);
	ret = send_video_command(pdev, 4 /* pdev->vendpoint */, buf, 12);
@@ -358,8 +338,6 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
	memcpy(pdev->cmd_buf, buf, 12);
	memcpy(pdev->cmd_buf, buf, 12);
	/* All set and go */
	/* All set and go */
	pdev->vframes = frames;
	pdev->vframes = frames;
	pdev->vsize = size;
	pdev->vsnapshot = snapshot;
	pdev->valternate = pChoose->alternate;
	pdev->valternate = pChoose->alternate;
	pdev->image = pwc_image_sizes[size];
	pdev->image = pwc_image_sizes[size];
	pdev->vbandlength = pChoose->bandlength;
	pdev->vbandlength = pChoose->bandlength;
@@ -367,8 +345,8 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
		pdev->frame_size = (pdev->vbandlength * pdev->image.y) / 4;
		pdev->frame_size = (pdev->vbandlength * pdev->image.y) / 4;
	else
	else
		pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8;
		pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8;
	PWC_TRACE("frame_size=%d, vframes=%d, vsize=%d, vsnapshot=%d, vbandlength=%d\n",
	PWC_TRACE("frame_size=%d, vframes=%d, vsize=%d, vbandlength=%d\n",
	    pdev->frame_size,pdev->vframes,pdev->vsize,pdev->vsnapshot,pdev->vbandlength);
	    pdev->frame_size, pdev->vframes, size, pdev->vbandlength);
	return 0;
	return 0;
}
}


@@ -380,9 +358,9 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
   @height: viewport height
   @height: viewport height
   @frame: framerate, in fps
   @frame: framerate, in fps
   @compression: preferred compression ratio
   @compression: preferred compression ratio
   @snapshot: snapshot mode or streaming
 */
 */
int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot)
int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
	int frames, int compression)
{
{
	int ret, size;
	int ret, size;


@@ -398,10 +376,10 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
		ret = set_video_mode_Nala(pdev, size, frames);
		ret = set_video_mode_Nala(pdev, size, frames);


	} else if (DEVICE_USE_CODEC3(pdev->type)) {
	} else if (DEVICE_USE_CODEC3(pdev->type)) {
		ret = set_video_mode_Kiara(pdev, size, frames, compression, snapshot);
		ret = set_video_mode_Kiara(pdev, size, frames, compression);


	} else {
	} else {
		ret = set_video_mode_Timon(pdev, size, frames, compression, snapshot);
		ret = set_video_mode_Timon(pdev, size, frames, compression);
	}
	}
	if (ret < 0) {
	if (ret < 0) {
		PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret);
		PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret);
@@ -852,7 +830,9 @@ long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
		if (ARGR(qual) < 0 || ARGR(qual) > 3)
		if (ARGR(qual) < 0 || ARGR(qual) > 3)
			ret = -EINVAL;
			ret = -EINVAL;
		else
		else
			ret = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, ARGR(qual), pdev->vsnapshot);
			ret = pwc_set_video_mode(pdev,
						 pdev->view.x, pdev->view.y,
						 pdev->vframes, ARGR(qual));
leave:
leave:
		mutex_unlock(&pdev->udevlock);
		mutex_unlock(&pdev->udevlock);
		break;
		break;
+27 −248
Original line number Original line Diff line number Diff line
@@ -51,13 +51,6 @@
# define USE_LOOKUP_TABLE_TO_CLAMP 1
# define USE_LOOKUP_TABLE_TO_CLAMP 1
#endif
#endif


/*
 * ENABLE_BAYER_DECODER
 *   0: bayer decoder is not build (save some space)
 *   1: bayer decoder is build and can be used
 */
#define ENABLE_BAYER_DECODER 0

static void build_subblock_pattern(struct pwc_dec23_private *pdec)
static void build_subblock_pattern(struct pwc_dec23_private *pdec)
{
{
	static const unsigned int initial_values[12] = {
	static const unsigned int initial_values[12] = {
@@ -469,123 +462,6 @@ static void copy_image_block_CrCb(const int *src, unsigned char *dst, unsigned i
#endif
#endif
}
}


#if ENABLE_BAYER_DECODER
/*
 * Format: 8x2 pixels
 *   . G . G . G . G . G . G . G
 *   . . . . . . . . . . . . . .
 *   . G . G . G . G . G . G . G
 *   . . . . . . . . . . . . . .
 *   or
 *   . . . . . . . . . . . . . .
 *   G . G . G . G . G . G . G .
 *   . . . . . . . . . . . . . .
 *   G . G . G . G . G . G . G .
*/
static void copy_image_block_Green(const int *src, unsigned char *dst, unsigned int bytes_per_line, unsigned int scalebits)
{
#if UNROLL_LOOP_FOR_COPY
	/* Unroll all loops */
	const unsigned char *cm = pwc_crop_table+MAX_OUTER_CROP_VALUE;
	unsigned char *d = dst;
	const int *c = src;

	d[0] = cm[c[0] >> scalebits];
	d[2] = cm[c[1] >> scalebits];
	d[4] = cm[c[2] >> scalebits];
	d[6] = cm[c[3] >> scalebits];
	d[8] = cm[c[4] >> scalebits];
	d[10] = cm[c[5] >> scalebits];
	d[12] = cm[c[6] >> scalebits];
	d[14] = cm[c[7] >> scalebits];

	d = dst + bytes_per_line;
	d[0] = cm[c[8] >> scalebits];
	d[2] = cm[c[9] >> scalebits];
	d[4] = cm[c[10] >> scalebits];
	d[6] = cm[c[11] >> scalebits];
	d[8] = cm[c[12] >> scalebits];
	d[10] = cm[c[13] >> scalebits];
	d[12] = cm[c[14] >> scalebits];
	d[14] = cm[c[15] >> scalebits];
#else
	int i;
	unsigned char *d;
	const int *c = src;

	d = dst;
	for (i = 0; i < 8; i++, c++)
		d[i*2] = CLAMP((*c) >> scalebits);

	d = dst + bytes_per_line;
	for (i = 0; i < 8; i++, c++)
		d[i*2] = CLAMP((*c) >> scalebits);
#endif
}
#endif

#if ENABLE_BAYER_DECODER
/*
 * Format: 4x4 pixels
 *   R . R . R . R
 *   . B . B . B .
 *   R . R . R . R
 *   . B . B . B .
 */
static void copy_image_block_RedBlue(const int *src, unsigned char *dst, unsigned int bytes_per_line, unsigned int scalebits)
{
#if UNROLL_LOOP_FOR_COPY
	/* Unroll all loops */
	const unsigned char *cm = pwc_crop_table+MAX_OUTER_CROP_VALUE;
	unsigned char *d = dst;
	const int *c = src;

	d[0] = cm[c[0] >> scalebits];
	d[2] = cm[c[1] >> scalebits];
	d[4] = cm[c[2] >> scalebits];
	d[6] = cm[c[3] >> scalebits];

	d = dst + bytes_per_line;
	d[1] = cm[c[4] >> scalebits];
	d[3] = cm[c[5] >> scalebits];
	d[5] = cm[c[6] >> scalebits];
	d[7] = cm[c[7] >> scalebits];

	d = dst + bytes_per_line*2;
	d[0] = cm[c[8] >> scalebits];
	d[2] = cm[c[9] >> scalebits];
	d[4] = cm[c[10] >> scalebits];
	d[6] = cm[c[11] >> scalebits];

	d = dst + bytes_per_line*3;
	d[1] = cm[c[12] >> scalebits];
	d[3] = cm[c[13] >> scalebits];
	d[5] = cm[c[14] >> scalebits];
	d[7] = cm[c[15] >> scalebits];
#else
	int i;
	unsigned char *d;
	const int *c = src;

	d = dst;
	for (i = 0; i < 4; i++, c++)
		d[i*2] = CLAMP((*c) >> scalebits);

	d = dst + bytes_per_line;
	for (i = 0; i < 4; i++, c++)
		d[i*2+1] = CLAMP((*c) >> scalebits);

	d = dst + bytes_per_line*2;
	for (i = 0; i < 4; i++, c++)
		d[i*2] = CLAMP((*c) >> scalebits);

	d = dst + bytes_per_line*3;
	for (i = 0; i < 4; i++, c++)
		d[i*2+1] = CLAMP((*c) >> scalebits);
#endif
}
#endif

/*
/*
 * To manage the stream, we keep bits in a 32 bits register.
 * To manage the stream, we keep bits in a 32 bits register.
 * fill_nbits(n): fill the reservoir with at least n bits
 * fill_nbits(n): fill the reservoir with at least n bits
@@ -777,71 +653,6 @@ static void DecompressBand23(struct pwc_dec23_private *pdec,


}
}


#if ENABLE_BAYER_DECODER
/*
 * Size need to be a multiple of 8 in width
 *
 * Return a block of four line encoded like this:
 *
 *   G R G R G R G R G R G R G R G R
 *   B G B G B G B G B G B G B G B G
 *   G R G R G R G R G R G R G R G R
 *   B G B G B G B G B G B G B G B G
 *
 */
static void DecompressBandBayer(struct pwc_dec23_private *pdec,
				const unsigned char *rawyuv,
				unsigned char *rgbbayer,
				unsigned int   compressed_image_width,
				unsigned int   real_image_width)
{
	int compression_index, nblocks;
	const unsigned char *ptable0004;
	const unsigned char *ptable8004;
	unsigned char *dest;

	pdec->reservoir = 0;
	pdec->nbits_in_reservoir = 0;
	pdec->stream = rawyuv + 1;	/* The first byte of the stream is skipped */

	get_nbits(pdec, 4, compression_index);

	/* pass 1: uncompress RB component */
	nblocks = compressed_image_width / 4;

	ptable0004 = pdec->table_0004_pass1[compression_index];
	ptable8004 = pdec->table_8004_pass1[compression_index];
	dest = rgbbayer;

	/* Each block decode a square of 4x4 */
	while (nblocks) {
		decode_block(pdec, ptable0004, ptable8004);
		copy_image_block_RedBlue(pdec->temp_colors, rgbbayer, real_image_width, pdec->scalebits);
		dest += 8;
		nblocks--;
	}

	/* pass 2: uncompress G component */
	nblocks = compressed_image_width / 8;

	ptable0004 = pdec->table_0004_pass2[compression_index];
	ptable8004 = pdec->table_8004_pass2[compression_index];

	/* Each block decode a square of 4x4 */
	while (nblocks) {
		decode_block(pdec, ptable0004, ptable8004);
		copy_image_block_Green(pdec->temp_colors, rgbbayer+1, real_image_width, pdec->scalebits);

		decode_block(pdec, ptable0004, ptable8004);
		copy_image_block_Green(pdec->temp_colors, rgbbayer+real_image_width, real_image_width, pdec->scalebits);

		rgbbayer += 16;
		nblocks -= 2;
	}
}
#endif


/**
/**
 *
 *
 * Uncompress a pwc23 buffer.
 * Uncompress a pwc23 buffer.
@@ -852,52 +663,24 @@ static void DecompressBandBayer(struct pwc_dec23_private *pdec,
 *
 *
 * src: raw data
 * src: raw data
 * dst: image output
 * dst: image output
 * flags: PWCX_FLAG_PLANAR or PWCX_FLAG_BAYER
 */
 */
void pwc_dec23_decompress(const struct pwc_device *pwc,
void pwc_dec23_decompress(const struct pwc_device *pwc,
			  const void *src,
			  const void *src,
			  void *dst,
			  void *dst)
			  int flags)
{
{
	int bandlines_left, stride, bytes_per_block;
	int bandlines_left, stride, bytes_per_block;
	struct pwc_dec23_private *pdec = pwc->decompress_data;
	struct pwc_dec23_private *pdec = pwc->decompress_data;


	mutex_lock(&pdec->lock);

	bandlines_left = pwc->image.y / 4;
	bytes_per_block = pwc->view.x * 4;

	if (flags & PWCX_FLAG_BAYER) {
#if ENABLE_BAYER_DECODER
		/* RGB Bayer format */
		unsigned char *rgbout;

		stride = pwc->view.x * pwc->offset.y;
		rgbout = dst + stride + pwc->offset.x;


		while (bandlines_left--) {

			DecompressBandBayer(pwc->decompress_data,
					    src,
					    rgbout,
					    pwc->image.x, pwc->view.x);

			src += pwc->vbandlength;
			rgbout += bytes_per_block;

		}
#else
		memset(dst, 0, pwc->view.x * pwc->view.y);
#endif

	} else {
	/* YUV420P image format */
	/* YUV420P image format */
	unsigned char *pout_planar_y;
	unsigned char *pout_planar_y;
	unsigned char *pout_planar_u;
	unsigned char *pout_planar_u;
	unsigned char *pout_planar_v;
	unsigned char *pout_planar_v;
	unsigned int   plane_size;
	unsigned int   plane_size;


	mutex_lock(&pdec->lock);

	bandlines_left = pwc->image.y / 4;
	bytes_per_block = pwc->view.x * 4;
	plane_size = pwc->view.x * pwc->view.y;
	plane_size = pwc->view.x * pwc->view.y;


	/* offset in Y plane */
	/* offset in Y plane */
@@ -910,7 +693,6 @@ void pwc_dec23_decompress(const struct pwc_device *pwc,
	pout_planar_v = dst + plane_size + plane_size / 4 + stride;
	pout_planar_v = dst + plane_size + plane_size / 4 + stride;


	while (bandlines_left--) {
	while (bandlines_left--) {

		DecompressBand23(pwc->decompress_data,
		DecompressBand23(pwc->decompress_data,
				 src,
				 src,
				 pout_planar_y, pout_planar_u, pout_planar_v,
				 pout_planar_y, pout_planar_u, pout_planar_v,
@@ -919,9 +701,6 @@ void pwc_dec23_decompress(const struct pwc_device *pwc,
		pout_planar_y += bytes_per_block;
		pout_planar_y += bytes_per_block;
		pout_planar_u += pwc->view.x;
		pout_planar_u += pwc->view.x;
		pout_planar_v += pwc->view.x;
		pout_planar_v += pwc->view.x;

	}
	}
	}

	mutex_unlock(&pdec->lock);
	mutex_unlock(&pdec->lock);
}
}
+1 −2
Original line number Original line Diff line number Diff line
@@ -54,6 +54,5 @@ struct pwc_dec23_private
int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd);
int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd);
void pwc_dec23_decompress(const struct pwc_device *pwc,
void pwc_dec23_decompress(const struct pwc_device *pwc,
			  const void *src,
			  const void *src,
			  void *dst,
			  void *dst);
			  int flags);
#endif
#endif
+2 −3
Original line number Original line Diff line number Diff line
@@ -743,8 +743,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
	if (pdev->power_save) {
	if (pdev->power_save) {
		/* Restore video mode */
		/* Restore video mode */
		pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y,
		pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y,
				   pdev->vframes, pdev->vcompression,
				   pdev->vframes, pdev->vcompression);
				   pdev->vsnapshot);
	}
	}
	pwc_set_leds(pdev, led_on, led_off);
	pwc_set_leds(pdev, led_on, led_off);


@@ -1131,7 +1130,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id


	/* Setup intial videomode */
	/* Setup intial videomode */
	rc = pwc_set_video_mode(pdev, pdev->view_max.x, pdev->view_max.y,
	rc = pwc_set_video_mode(pdev, pdev->view_max.x, pdev->view_max.y,
				pdev->vframes, pdev->vcompression, 0);
				pdev->vframes, pdev->vcompression);
	if (rc)
	if (rc)
		goto err_free_mem;
		goto err_free_mem;


+1 −7
Original line number Original line Diff line number Diff line
@@ -111,12 +111,6 @@ int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf)
	 * the decompressor routines will write the data in planar format
	 * the decompressor routines will write the data in planar format
	 * immediately.
	 * immediately.
	 */
	 */
	if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot) {
		PWC_ERROR("Mode Bayer is not supported for now\n");
		/* flags |= PWCX_FLAG_BAYER; */
		return -ENXIO; /* No such device or address: missing decompressor */
	}

	if (DEVICE_USE_CODEC1(pdev->type)) {
	if (DEVICE_USE_CODEC1(pdev->type)) {


		/* TODO & FIXME */
		/* TODO & FIXME */
@@ -124,7 +118,7 @@ int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf)
		return -ENXIO; /* No such device or address: missing decompressor */
		return -ENXIO; /* No such device or address: missing decompressor */


	} else {
	} else {
		pwc_dec23_decompress(pdev, yuv, image, PWCX_FLAG_PLANAR);
		pwc_dec23_decompress(pdev, yuv, image);
	}
	}
	return 0;
	return 0;
}
}
Loading