Commit cd2e34ea authored by Ondrej Zary's avatar Ondrej Zary Committed by Mauro Carvalho Chehab

[media] bttv: stop abusing mbox_we for sw_status

Kodicom 4400R and Geovision GV-800 code in bttv driver abuses mbox_we (int)
in struct bttv as char *.
Remove this hack and add a proper sw_status array to struct bttv instead.
This is a a preparation to remove mbox_we.
Signed-off-by: default avatarOndrej Zary <linux@rainbow-software.org>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 8fd79579
...@@ -4441,9 +4441,7 @@ static void tibetCS16_init(struct bttv *btv) ...@@ -4441,9 +4441,7 @@ static void tibetCS16_init(struct bttv *btv)
* is {3, 0, 2, 1}, i.e. the first controller to be detected is logical * is {3, 0, 2, 1}, i.e. the first controller to be detected is logical
* unit 3, the second (which is the master) is logical unit 0, etc. * unit 3, the second (which is the master) is logical unit 0, etc.
* We need to maintain the status of the analog switch (which of the 16 * We need to maintain the status of the analog switch (which of the 16
* cameras is connected to which of the 4 controllers). Rather than * cameras is connected to which of the 4 controllers) in sw_status array.
* add to the bttv structure for this, we use the data reserved for
* the mbox (unused for this card type).
*/ */
/* /*
...@@ -4478,7 +4476,6 @@ static void kodicom4400r_write(struct bttv *btv, ...@@ -4478,7 +4476,6 @@ static void kodicom4400r_write(struct bttv *btv,
*/ */
static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input) static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
{ {
char *sw_status;
int xaddr, yaddr; int xaddr, yaddr;
struct bttv *mctlr; struct bttv *mctlr;
static unsigned char map[4] = {3, 0, 2, 1}; static unsigned char map[4] = {3, 0, 2, 1};
...@@ -4489,14 +4486,13 @@ static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input) ...@@ -4489,14 +4486,13 @@ static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
} }
yaddr = (btv->c.nr - mctlr->c.nr + 1) & 3; /* the '&' is for safety */ yaddr = (btv->c.nr - mctlr->c.nr + 1) & 3; /* the '&' is for safety */
yaddr = map[yaddr]; yaddr = map[yaddr];
sw_status = (char *)(&mctlr->mbox_we);
xaddr = input & 0xf; xaddr = input & 0xf;
/* Check if the controller/camera pair has changed, else ignore */ /* Check if the controller/camera pair has changed, else ignore */
if (sw_status[yaddr] != xaddr) if (mctlr->sw_status[yaddr] != xaddr)
{ {
/* "open" the old switch, "close" the new one, save the new */ /* "open" the old switch, "close" the new one, save the new */
kodicom4400r_write(mctlr, sw_status[yaddr], yaddr, 0); kodicom4400r_write(mctlr, mctlr->sw_status[yaddr], yaddr, 0);
sw_status[yaddr] = xaddr; mctlr->sw_status[yaddr] = xaddr;
kodicom4400r_write(mctlr, xaddr, yaddr, 1); kodicom4400r_write(mctlr, xaddr, yaddr, 1);
} }
} }
...@@ -4509,7 +4505,6 @@ static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input) ...@@ -4509,7 +4505,6 @@ static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input)
*/ */
static void kodicom4400r_init(struct bttv *btv) static void kodicom4400r_init(struct bttv *btv)
{ {
char *sw_status = (char *)(&btv->mbox_we);
int ix; int ix;
gpio_inout(0x0003ff, 0x0003ff); gpio_inout(0x0003ff, 0x0003ff);
...@@ -4517,7 +4512,7 @@ static void kodicom4400r_init(struct bttv *btv) ...@@ -4517,7 +4512,7 @@ static void kodicom4400r_init(struct bttv *btv)
gpio_write(0); gpio_write(0);
/* Preset camera 0 to the 4 controllers */ /* Preset camera 0 to the 4 controllers */
for (ix = 0; ix < 4; ix++) { for (ix = 0; ix < 4; ix++) {
sw_status[ix] = ix; btv->sw_status[ix] = ix;
kodicom4400r_write(btv, ix, ix, 1); kodicom4400r_write(btv, ix, ix, 1);
} }
/* /*
...@@ -4794,7 +4789,6 @@ static void gv800s_write(struct bttv *btv, ...@@ -4794,7 +4789,6 @@ static void gv800s_write(struct bttv *btv,
static void gv800s_muxsel(struct bttv *btv, unsigned int input) static void gv800s_muxsel(struct bttv *btv, unsigned int input)
{ {
struct bttv *mctlr; struct bttv *mctlr;
char *sw_status;
int xaddr, yaddr; int xaddr, yaddr;
static unsigned int map[4][4] = { { 0x0, 0x4, 0xa, 0x6 }, static unsigned int map[4][4] = { { 0x0, 0x4, 0xa, 0x6 },
{ 0x1, 0x5, 0xb, 0x7 }, { 0x1, 0x5, 0xb, 0x7 },
...@@ -4807,14 +4801,13 @@ static void gv800s_muxsel(struct bttv *btv, unsigned int input) ...@@ -4807,14 +4801,13 @@ static void gv800s_muxsel(struct bttv *btv, unsigned int input)
return; return;
} }
yaddr = (btv->c.nr - mctlr->c.nr) & 3; yaddr = (btv->c.nr - mctlr->c.nr) & 3;
sw_status = (char *)(&mctlr->mbox_we);
xaddr = map[yaddr][input] & 0xf; xaddr = map[yaddr][input] & 0xf;
/* Check if the controller/camera pair has changed, ignore otherwise */ /* Check if the controller/camera pair has changed, ignore otherwise */
if (sw_status[yaddr] != xaddr) { if (mctlr->sw_status[yaddr] != xaddr) {
/* disable the old switch, enable the new one and save status */ /* disable the old switch, enable the new one and save status */
gv800s_write(mctlr, sw_status[yaddr], yaddr, 0); gv800s_write(mctlr, mctlr->sw_status[yaddr], yaddr, 0);
sw_status[yaddr] = xaddr; mctlr->sw_status[yaddr] = xaddr;
gv800s_write(mctlr, xaddr, yaddr, 1); gv800s_write(mctlr, xaddr, yaddr, 1);
} }
} }
...@@ -4822,7 +4815,6 @@ static void gv800s_muxsel(struct bttv *btv, unsigned int input) ...@@ -4822,7 +4815,6 @@ static void gv800s_muxsel(struct bttv *btv, unsigned int input)
/* GeoVision GV-800(S) "master" chip init */ /* GeoVision GV-800(S) "master" chip init */
static void gv800s_init(struct bttv *btv) static void gv800s_init(struct bttv *btv)
{ {
char *sw_status = (char *)(&btv->mbox_we);
int ix; int ix;
gpio_inout(0xf107f, 0xf107f); gpio_inout(0xf107f, 0xf107f);
...@@ -4831,7 +4823,7 @@ static void gv800s_init(struct bttv *btv) ...@@ -4831,7 +4823,7 @@ static void gv800s_init(struct bttv *btv)
/* Preset camera 0 to the 4 controllers */ /* Preset camera 0 to the 4 controllers */
for (ix = 0; ix < 4; ix++) { for (ix = 0; ix < 4; ix++) {
sw_status[ix] = ix; btv->sw_status[ix] = ix;
gv800s_write(btv, ix, ix, 1); gv800s_write(btv, ix, ix, 1);
} }
......
...@@ -459,6 +459,9 @@ struct bttv { ...@@ -459,6 +459,9 @@ struct bttv {
int mbox_iow; int mbox_iow;
int mbox_csel; int mbox_csel;
/* switch status for multi-controller cards */
char sw_status[4];
/* risc memory management data /* risc memory management data
- must acquire s_lock before changing these - must acquire s_lock before changing these
- only the irq handler is supported to touch top + bottom + vcurr */ - only the irq handler is supported to touch top + bottom + vcurr */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment