All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: "Jasmin J." <jasmin@anw.at>
Cc: linux-media@vger.kernel.org, max.kellermann@gmail.com,
	rjkm@metzlerbros.de, d.scheller@gmx.net
Subject: Re: [PATCH 3/7] [media] dvb-core/dvb_ca_en50221.c: Add block read/write functions
Date: Sat, 24 Jun 2017 16:16:13 -0300	[thread overview]
Message-ID: <20170624161613.4a08314c@vento.lan> (raw)
In-Reply-To: <1494190313-18557-4-git-send-email-jasmin@anw.at>

Em Sun,  7 May 2017 22:51:49 +0200
"Jasmin J." <jasmin@anw.at> escreveu:

> From: Jasmin Jessich <jasmin@anw.at>
> 
> Some lower level drivers may work better when sending blocks of data instead
> byte per byte. For this we need new function pointers in the dvb_ca_en50221
> protocol structure (read_data, write_data) and the protocol needs to execute
> them, if they are defined.
> Block data transmission is done in all states expect LINKINIT.
> 
> Signed-off-by: Ralph Metzler <rjkm@metzlerbros.de>
> Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
> Signed-off-by: Jasmin Jessich <jasmin@anw.at>

Please check the patch with checkpatch.pl:

WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#16: 
Some lower level drivers may work better when sending blocks of data instead

WARNING: line over 80 characters
#54: FILE: drivers/media/dvb-core/dvb_ca_en50221.c:649:
+	if (ca->pub->read_data && (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_LINKINIT)) {

...



> ---
>  drivers/media/dvb-core/dvb_ca_en50221.c | 117 ++++++++++++++++++--------------
>  drivers/media/dvb-core/dvb_ca_en50221.h |   7 ++
>  2 files changed, 73 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
> index 1cdd80a..cc709c9 100644
> --- a/drivers/media/dvb-core/dvb_ca_en50221.c
> +++ b/drivers/media/dvb-core/dvb_ca_en50221.c
> @@ -646,66 +646,78 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
>  		}
>  	}
>  
> -	/* check if there is data available */
> -	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
> -		goto exit;
> -	if (!(status & STATUSREG_DA)) {
> -		/* no data */
> -		status = 0;
> -		goto exit;
> -	}
> -
> -	/* read the amount of data */
> -	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH)) < 0)
> -		goto exit;
> -	bytes_read = status << 8;
> -	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW)) < 0)
> -		goto exit;
> -	bytes_read |= status;
> +	if (ca->pub->read_data && (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_LINKINIT)) {
> +		if (ebuf == NULL)
> +			status = ca->pub->read_data(ca->pub, slot, buf, sizeof(buf));
> +		else
> +			status = ca->pub->read_data(ca->pub, slot, buf, ecount);
> +		if (status < 0)
> +			return status;
> +		bytes_read =  status;
> +		if (status == 0)
> +			goto exit;
> +	} else {
>  
> -	/* check it will fit */
> -	if (ebuf == NULL) {
> -		if (bytes_read > ca->slot_info[slot].link_buf_size) {
> -			pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
> -			       ca->dvbdev->adapter->num, bytes_read,
> -			       ca->slot_info[slot].link_buf_size);
> -			ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
> -			status = -EIO;
> +		/* check if there is data available */
> +		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
>  			goto exit;
> -		}
> -		if (bytes_read < 2) {
> -			pr_err("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
> -			       ca->dvbdev->adapter->num);
> -			ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
> -			status = -EIO;
> +		if (!(status & STATUSREG_DA)) {
> +			/* no data */
> +			status = 0;
>  			goto exit;
>  		}
> -	} else {
> -		if (bytes_read > ecount) {
> -			pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the ecount size!\n",
> -			       ca->dvbdev->adapter->num);
> -			status = -EIO;
> +
> +		/* read the amount of data */
> +		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH)) < 0)
> +			goto exit;
> +		bytes_read = status << 8;
> +		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW)) < 0)
>  			goto exit;
> +		bytes_read |= status;
> +
> +		/* check it will fit */
> +		if (ebuf == NULL) {
> +			if (bytes_read > ca->slot_info[slot].link_buf_size) {
> +				pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
> +				       ca->dvbdev->adapter->num, bytes_read, ca->slot_info[slot].link_buf_size);
> +				ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
> +				status = -EIO;
> +				goto exit;
> +			}
> +			if (bytes_read < 2) {
> +				pr_err("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
> +				       ca->dvbdev->adapter->num);
> +				ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
> +				status = -EIO;
> +				goto exit;
> +			}
> +		} else {
> +			if (bytes_read > ecount) {
> +				pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the ecount size!\n",
> +				       ca->dvbdev->adapter->num);
> +				status = -EIO;
> +				goto exit;
> +			}
>  		}
> -	}
>  
> -	/* fill the buffer */
> -	for (i = 0; i < bytes_read; i++) {
> -		/* read byte and check */
> -		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_DATA)) < 0)
> -			goto exit;
> +		/* fill the buffer */
> +		for (i = 0; i < bytes_read; i++) {
> +			/* read byte and check */
> +			if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_DATA)) < 0)
> +				goto exit;
>  
> -		/* OK, store it in the buffer */
> -		buf[i] = status;
> -	}
> +			/* OK, store it in the buffer */
> +			buf[i] = status;
> +		}
>  
> -	/* check for read error (RE should now be 0) */
> -	if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
> -		goto exit;
> -	if (status & STATUSREG_RE) {
> -		ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
> -		status = -EIO;
> -		goto exit;
> +		/* check for read error (RE should now be 0) */
> +		if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
> +			goto exit;
> +		if (status & STATUSREG_RE) {
> +			ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
> +			status = -EIO;
> +			goto exit;
> +		}
>  	}
>  
>  	/* OK, add it to the receive buffer, or copy into external buffer if supplied */
> @@ -757,6 +769,9 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
>  	if (bytes_write > ca->slot_info[slot].link_buf_size)
>  		return -EINVAL;
>  
> +	if (ca->pub->write_data && (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_LINKINIT))
> +		return ca->pub->write_data(ca->pub, slot, buf, bytes_write);
> +
>  	/* it is possible we are dealing with a single buffer implementation,
>  	   thus if there is data available for read or if there is even a read
>  	   already in progress, we do nothing but awake the kernel thread to
> diff --git a/drivers/media/dvb-core/dvb_ca_en50221.h b/drivers/media/dvb-core/dvb_ca_en50221.h
> index 1e4bbbd..82617ba 100644
> --- a/drivers/media/dvb-core/dvb_ca_en50221.h
> +++ b/drivers/media/dvb-core/dvb_ca_en50221.h
> @@ -41,6 +41,8 @@
>   * @write_attribute_mem: function for writing attribute memory on the CAM
>   * @read_cam_control:	function for reading the control interface on the CAM
>   * @write_cam_control:	function for reading the control interface on the CAM
> + * @read_data:		function for reading data (block mode)
> + * @write_data:		function for writing data (block mode)
>   * @slot_reset:		function to reset the CAM slot
>   * @slot_shutdown:	function to shutdown a CAM slot
>   * @slot_ts_enable:	function to enable the Transport Stream on a CAM slot
> @@ -66,6 +68,11 @@ struct dvb_ca_en50221 {
>  	int (*write_cam_control)(struct dvb_ca_en50221 *ca,
>  				 int slot, u8 address, u8 value);
>  
> +	int (*read_data)(struct dvb_ca_en50221 *ca,
> +				int slot, u8 *ebuf, int ecount);
> +	int (*write_data)(struct dvb_ca_en50221 *ca,
> +				int slot, u8 *ebuf, int ecount);
> +
>  	int (*slot_reset)(struct dvb_ca_en50221 *ca, int slot);
>  	int (*slot_shutdown)(struct dvb_ca_en50221 *ca, int slot);
>  	int (*slot_ts_enable)(struct dvb_ca_en50221 *ca, int slot);



Thanks,
Mauro

  reply	other threads:[~2017-06-24 19:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07 20:51 [PATCH 0/7] Add block read/write to en50221 CAM functions Jasmin J.
2017-05-07 20:51 ` [PATCH 1/7] [media] dvb-core/dvb_ca_en50221.c: State UNINITIALISED instead of INVALID Jasmin J.
2017-05-07 20:51 ` [PATCH 2/7] [media] dvb-core/dvb_ca_en50221.c: Increase timeout for link init Jasmin J.
2017-05-07 20:51 ` [PATCH 3/7] [media] dvb-core/dvb_ca_en50221.c: Add block read/write functions Jasmin J.
2017-06-24 19:16   ` Mauro Carvalho Chehab [this message]
2017-06-24 19:36     ` Jasmin J.
2017-06-24 20:03       ` Jasmin J.
2017-05-07 20:51 ` [PATCH 4/7] [staging] cxd2099/cxd2099.c/.h: Fixed buffer mode Jasmin J.
2017-05-07 20:51 ` [PATCH 5/7] [media] ddbridge/ddbridge-core.c: Set maximum cxd2099 block size to 512 Jasmin J.
2017-06-24 19:07   ` Mauro Carvalho Chehab
2017-05-07 20:51 ` [PATCH 6/7] [staging] cxd2099/cxd2099.c: Removed useless printing in cxd2099 driver Jasmin J.
2017-06-24 19:12   ` Mauro Carvalho Chehab
2017-05-07 20:51 ` [PATCH 7/7] [staging] cxd2099/cxd2099.c: Activate cxd2099 buffer mode Jasmin J.
2017-06-24 19:09   ` Mauro Carvalho Chehab
2017-06-07 15:57 ` [PATCH 0/7] Add block read/write to en50221 CAM functions Mauro Carvalho Chehab
2017-06-07 19:18   ` Jasmin J.
2017-06-07 22:49     ` Mauro Carvalho Chehab
2017-06-08  7:31       ` Jasmin J.
2017-06-08  8:44         ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170624161613.4a08314c@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=d.scheller@gmx.net \
    --cc=jasmin@anw.at \
    --cc=linux-media@vger.kernel.org \
    --cc=max.kellermann@gmail.com \
    --cc=rjkm@metzlerbros.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.