public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <m.chehab@samsung.com>
To: James Hogan <james.hogan@imgtec.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 10/11] media: rc: img-ir: add Sharp decoder module
Date: Sun, 22 Dec 2013 12:01:14 -0200	[thread overview]
Message-ID: <20131222120114.7aecbf9e@samsung.com> (raw)
In-Reply-To: <1386947579-26703-11-git-send-email-james.hogan@imgtec.com>

Em Fri, 13 Dec 2013 15:12:58 +0000
James Hogan <james.hogan@imgtec.com> escreveu:

> Add an img-ir module for decoding the Sharp infrared protocol.

Patches 5 and 7-11 look OK to me.

While not required for patchset acceptance, it would be great if you could
also add an IR raw decoder for this protocol, specially if you can also
test it.

> 
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
> Cc: linux-media@vger.kernel.org
> ---
>  drivers/media/rc/img-ir/Kconfig        |   7 ++
>  drivers/media/rc/img-ir/Makefile       |   1 +
>  drivers/media/rc/img-ir/img-ir-sharp.c | 115 +++++++++++++++++++++++++++++++++
>  3 files changed, 123 insertions(+)
>  create mode 100644 drivers/media/rc/img-ir/img-ir-sharp.c
> 
> diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
> index 38505188df0e..24e0966a3220 100644
> --- a/drivers/media/rc/img-ir/Kconfig
> +++ b/drivers/media/rc/img-ir/Kconfig
> @@ -45,3 +45,10 @@ config IR_IMG_SONY
>  	help
>  	   Say Y or M here to enable support for the Sony protocol in the ImgTec
>  	   infrared decoder block.
> +
> +config IR_IMG_SHARP
> +	tristate "Sharp protocol support"
> +	depends on IR_IMG && IR_IMG_HW
> +	help
> +	   Say Y or M here to enable support for the Sharp protocol in the
> +	   ImgTec infrared decoder block.
> diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
> index f3e7cc4f32e4..3c3ab4f1a9f1 100644
> --- a/drivers/media/rc/img-ir/Makefile
> +++ b/drivers/media/rc/img-ir/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_IR_IMG)		+= img-ir.o
>  obj-$(CONFIG_IR_IMG_NEC)	+= img-ir-nec.o
>  obj-$(CONFIG_IR_IMG_JVC)	+= img-ir-jvc.o
>  obj-$(CONFIG_IR_IMG_SONY)	+= img-ir-sony.o
> +obj-$(CONFIG_IR_IMG_SHARP)	+= img-ir-sharp.o
> diff --git a/drivers/media/rc/img-ir/img-ir-sharp.c b/drivers/media/rc/img-ir/img-ir-sharp.c
> new file mode 100644
> index 000000000000..4d70abc088b4
> --- /dev/null
> +++ b/drivers/media/rc/img-ir/img-ir-sharp.c
> @@ -0,0 +1,115 @@
> +/*
> + * ImgTec IR Decoder setup for Sharp protocol.
> + *
> + * Copyright 2012-2013 Imagination Technologies Ltd.
> + */
> +
> +#include <linux/module.h>
> +
> +#include "img-ir-hw.h"
> +
> +/* Convert Sharp data to a scancode */
> +static int img_ir_sharp_scancode(int len, u64 raw, u64 protocols)
> +{
> +	unsigned int addr, cmd, exp, chk;
> +
> +	if (len != 15)
> +		return IMG_IR_ERR_INVALID;
> +
> +	addr = (raw >>   0) & 0x1f;
> +	cmd  = (raw >>   5) & 0xff;
> +	exp  = (raw >>  13) &  0x1;
> +	chk  = (raw >>  14) &  0x1;
> +
> +	/* validate data */
> +	if (!exp)
> +		return IMG_IR_ERR_INVALID;
> +	if (chk)
> +		/* probably the second half of the message */
> +		return IMG_IR_ERR_INVALID;
> +
> +	return addr << 8 | cmd;
> +}
> +
> +/* Convert Sharp scancode to Sharp data filter */
> +static int img_ir_sharp_filter(const struct img_ir_sc_filter *in,
> +			       struct img_ir_filter *out, u64 protocols)
> +{
> +	unsigned int addr, cmd, exp = 0, chk = 0;
> +	unsigned int addr_m, cmd_m, exp_m = 0, chk_m = 0;
> +
> +	addr   = (in->data >> 8) & 0x1f;
> +	addr_m = (in->mask >> 8) & 0x1f;
> +	cmd    = (in->data >> 0) & 0xff;
> +	cmd_m  = (in->mask >> 0) & 0xff;
> +	if (cmd_m) {
> +		/* if filtering commands, we can only match the first part */
> +		exp   = 1;
> +		exp_m = 1;
> +		chk   = 0;
> +		chk_m = 1;
> +	}
> +
> +	out->data = addr        |
> +		    cmd   <<  5 |
> +		    exp   << 13 |
> +		    chk   << 14;
> +	out->mask = addr_m      |
> +		    cmd_m <<  5 |
> +		    exp_m << 13 |
> +		    chk_m << 14;
> +
> +	return 0;
> +}
> +
> +/*
> + * Sharp decoder
> + * See also http://www.sbprojects.com/knowledge/ir/sharp.php
> + */
> +static struct img_ir_decoder img_ir_sharp = {
> +	.type = RC_BIT_SHARP,
> +	.control = {
> +		.decoden = 0,
> +		.decodend2 = 1,
> +		.code_type = IMG_IR_CODETYPE_PULSEDIST,
> +		.d1validsel = 1,
> +	},
> +	/* main timings */
> +	.timings = {
> +		/* 0 symbol */
> +		.s10 = {
> +			.pulse = { 320	/* 320 us */ },
> +			.space = { 680	/* 1 ms period */ },
> +		},
> +		/* 1 symbol */
> +		.s11 = {
> +			.pulse = { 320	/* 230 us */ },
> +			.space = { 1680	/* 2 ms period */ },
> +		},
> +		/* free time */
> +		.ft = {
> +			.minlen = 15,
> +			.maxlen = 15,
> +			.ft_min = 5000,	/* 5 ms */
> +		},
> +	},
> +	/* scancode logic */
> +	.scancode = img_ir_sharp_scancode,
> +	.filter = img_ir_sharp_filter,
> +};
> +
> +static int __init img_ir_sharp_init(void)
> +{
> +	return img_ir_register_decoder(&img_ir_sharp);
> +}
> +module_init(img_ir_sharp_init);
> +
> +static void __exit img_ir_sharp_exit(void)
> +{
> +	img_ir_unregister_decoder(&img_ir_sharp);
> +}
> +module_exit(img_ir_sharp_exit);
> +
> +MODULE_AUTHOR("Imagination Technologies Ltd.");
> +MODULE_DESCRIPTION("ImgTec IR Sharp protocol support");
> +MODULE_LICENSE("GPL");


-- 

Cheers,
Mauro

  reply	other threads:[~2013-12-22 14:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13 15:12 [PATCH 00/11] media: rc: ImgTec IR decoder driver James Hogan
2013-12-13 15:12 ` [PATCH 01/11] dt: binding: add binding for ImgTec IR block James Hogan
2013-12-22 10:56   ` Mauro Carvalho Chehab
2013-12-22 12:48   ` Tomasz Figa
2013-12-23 10:41     ` James Hogan
2013-12-13 15:12 ` [PATCH 02/11] media: rc: img-ir: add base driver James Hogan
2013-12-13 15:12 ` [PATCH 03/11] media: rc: img-ir: add raw driver James Hogan
2013-12-13 15:12 ` [PATCH 04/11] media: rc: img-ir: add hardware decoder driver James Hogan
2013-12-22 13:40   ` Mauro Carvalho Chehab
2013-12-23 13:17     ` James Hogan
2013-12-13 15:12 ` [PATCH 05/11] media: rc: img-ir: add to build James Hogan
2013-12-13 15:12 ` [PATCH 06/11] media: rc: img-ir: add NEC decoder module James Hogan
2013-12-22 13:49   ` Mauro Carvalho Chehab
2013-12-23 11:30     ` James Hogan
2013-12-13 15:12 ` [PATCH 07/11] media: rc: img-ir: add JVC " James Hogan
2013-12-13 15:12 ` [PATCH 08/11] media: rc: img-ir: add Sony " James Hogan
2013-12-13 15:12 ` [PATCH 09/11] media: rc: add Sharp infrared protocol James Hogan
2013-12-13 15:12 ` [PATCH 10/11] media: rc: img-ir: add Sharp decoder module James Hogan
2013-12-22 14:01   ` Mauro Carvalho Chehab [this message]
2013-12-23 12:04     ` James Hogan
2013-12-13 15:12 ` [PATCH 11/11] media: rc: img-ir: add Sanyo " James Hogan

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=20131222120114.7aecbf9e@samsung.com \
    --to=m.chehab@samsung.com \
    --cc=james.hogan@imgtec.com \
    --cc=linux-media@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox