Skip to content

Commit

Permalink
[media] mceusb: fix inverted mask inversion logic
Browse files Browse the repository at this point in the history
As it turns out, somewhere along the way, we managed to invert the
meaning of the tx_mask_inverted flag. Looking back over the old lirc
driver, tx_mask_inverted was set to 0 if the device was in tx_mask_list.
Now we have a tx_mask_inverted flag set to 1 for all the devices that
were in the list, and set tx_mask_inverted to that flag value, which is
actually the opposite of what we used to set, causing set_tx_mask to use
the wrong mask setting option. Since there seem to be more devices with
inverted masks than not (using the original device as the baseline for
inverted vs. normal), lets just call the ones currently marked as
inverted normal instead, and flip the if/else actions that key off of
the inverted flag.

Note: the problem only cropped up if a call to set_tx_mask was made, if
no mask was set, the device would work just fine, which is why this
managed to slip though w/o getting noticed until now.

Tested successfully by myself and Dennis Gilmore.

Reported-by: Dennis Gilmore <dgilmore@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Jarod Wilson authored and Mauro Carvalho Chehab committed Dec 20, 2010
1 parent fbb1f1b commit d8cc7fd
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions drivers/media/IR/mceusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct mceusb_model {
u32 mce_gen1:1;
u32 mce_gen2:1;
u32 mce_gen3:1;
u32 tx_mask_inverted:1;
u32 tx_mask_normal:1;
u32 is_polaris:1;
u32 no_tx:1;

Expand All @@ -167,18 +167,18 @@ struct mceusb_model {
static const struct mceusb_model mceusb_model[] = {
[MCE_GEN1] = {
.mce_gen1 = 1,
.tx_mask_inverted = 1,
.tx_mask_normal = 1,
},
[MCE_GEN2] = {
.mce_gen2 = 1,
},
[MCE_GEN2_TX_INV] = {
.mce_gen2 = 1,
.tx_mask_inverted = 1,
.tx_mask_normal = 1,
},
[MCE_GEN3] = {
.mce_gen3 = 1,
.tx_mask_inverted = 1,
.tx_mask_normal = 1,
},
[POLARIS_EVK] = {
.is_polaris = 1,
Expand Down Expand Up @@ -350,7 +350,7 @@ struct mceusb_dev {

struct {
u32 connected:1;
u32 tx_mask_inverted:1;
u32 tx_mask_normal:1;
u32 microsoft_gen1:1;
u32 no_tx:1;
} flags;
Expand Down Expand Up @@ -753,11 +753,11 @@ static int mceusb_set_tx_mask(void *priv, u32 mask)
{
struct mceusb_dev *ir = priv;

if (ir->flags.tx_mask_inverted)
if (ir->flags.tx_mask_normal)
ir->tx_mask = mask;
else
ir->tx_mask = (mask != MCE_DEFAULT_TX_MASK ?
mask ^ MCE_DEFAULT_TX_MASK : mask) << 1;
else
ir->tx_mask = mask;

return 0;
}
Expand Down Expand Up @@ -1117,7 +1117,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
enum mceusb_model_type model = id->driver_info;
bool is_gen3;
bool is_microsoft_gen1;
bool tx_mask_inverted;
bool tx_mask_normal;
bool is_polaris;

dev_dbg(&intf->dev, "%s called\n", __func__);
Expand All @@ -1126,7 +1126,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,

is_gen3 = mceusb_model[model].mce_gen3;
is_microsoft_gen1 = mceusb_model[model].mce_gen1;
tx_mask_inverted = mceusb_model[model].tx_mask_inverted;
tx_mask_normal = mceusb_model[model].tx_mask_normal;
is_polaris = mceusb_model[model].is_polaris;

if (is_polaris) {
Expand Down Expand Up @@ -1193,7 +1193,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
ir->dev = &intf->dev;
ir->len_in = maxp;
ir->flags.microsoft_gen1 = is_microsoft_gen1;
ir->flags.tx_mask_inverted = tx_mask_inverted;
ir->flags.tx_mask_normal = tx_mask_normal;
ir->flags.no_tx = mceusb_model[model].no_tx;
ir->model = model;

Expand Down

0 comments on commit d8cc7fd

Please sign in to comment.