Lines Matching refs:hdw
39 static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */ in pvr2_i2c_write() argument
49 if (length > (sizeof(hdw->cmd_buffer) - 3)) { in pvr2_i2c_write()
53 length,(unsigned int)(sizeof(hdw->cmd_buffer) - 3)); in pvr2_i2c_write()
57 LOCK_TAKE(hdw->ctl_lock); in pvr2_i2c_write()
60 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer)); in pvr2_i2c_write()
63 hdw->cmd_buffer[0] = FX2CMD_I2C_WRITE; /* write prefix */ in pvr2_i2c_write()
64 hdw->cmd_buffer[1] = i2c_addr; /* i2c addr of chip */ in pvr2_i2c_write()
65 hdw->cmd_buffer[2] = length; /* length of what follows */ in pvr2_i2c_write()
66 if (length) memcpy(hdw->cmd_buffer + 3, data, length); in pvr2_i2c_write()
69 ret = pvr2_send_request(hdw, in pvr2_i2c_write()
70 hdw->cmd_buffer, in pvr2_i2c_write()
72 hdw->cmd_buffer, in pvr2_i2c_write()
75 if (hdw->cmd_buffer[0] != 8) { in pvr2_i2c_write()
77 if (hdw->cmd_buffer[0] != 7) { in pvr2_i2c_write()
79 i2c_addr,hdw->cmd_buffer[0]); in pvr2_i2c_write()
84 LOCK_GIVE(hdw->ctl_lock); in pvr2_i2c_write()
89 static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */ in pvr2_i2c_read() argument
101 if (dlen > (sizeof(hdw->cmd_buffer) - 4)) { in pvr2_i2c_read()
105 dlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 4)); in pvr2_i2c_read()
108 if (res && (rlen > (sizeof(hdw->cmd_buffer) - 1))) { in pvr2_i2c_read()
112 rlen,(unsigned int)(sizeof(hdw->cmd_buffer) - 1)); in pvr2_i2c_read()
116 LOCK_TAKE(hdw->ctl_lock); in pvr2_i2c_read()
119 memset(hdw->cmd_buffer, 0, sizeof(hdw->cmd_buffer)); in pvr2_i2c_read()
122 hdw->cmd_buffer[0] = FX2CMD_I2C_READ; /* read prefix */ in pvr2_i2c_read()
123 hdw->cmd_buffer[1] = dlen; /* arg length */ in pvr2_i2c_read()
124 hdw->cmd_buffer[2] = rlen; /* answer length. Device will send one in pvr2_i2c_read()
126 hdw->cmd_buffer[3] = i2c_addr; /* i2c addr of chip */ in pvr2_i2c_read()
127 if (dlen) memcpy(hdw->cmd_buffer + 4, data, dlen); in pvr2_i2c_read()
130 ret = pvr2_send_request(hdw, in pvr2_i2c_read()
131 hdw->cmd_buffer, in pvr2_i2c_read()
133 hdw->cmd_buffer, in pvr2_i2c_read()
136 if (hdw->cmd_buffer[0] != 8) { in pvr2_i2c_read()
138 if (hdw->cmd_buffer[0] != 7) { in pvr2_i2c_read()
140 i2c_addr,hdw->cmd_buffer[0]); in pvr2_i2c_read()
151 memcpy(res, hdw->cmd_buffer + 1, rlen); in pvr2_i2c_read()
155 LOCK_GIVE(hdw->ctl_lock); in pvr2_i2c_read()
162 static int pvr2_i2c_basic_op(struct pvr2_hdw *hdw, in pvr2_i2c_basic_op() argument
172 return pvr2_i2c_read(hdw,i2c_addr,wdata,wlen,rdata,rlen); in pvr2_i2c_basic_op()
174 return pvr2_i2c_write(hdw,i2c_addr,wdata,wlen); in pvr2_i2c_basic_op()
185 static int i2c_24xxx_ir(struct pvr2_hdw *hdw, in i2c_24xxx_ir() argument
213 LOCK_TAKE(hdw->ctl_lock); do { in i2c_24xxx_ir()
214 hdw->cmd_buffer[0] = FX2CMD_GET_IR_CODE; in i2c_24xxx_ir()
215 stat = pvr2_send_request(hdw, in i2c_24xxx_ir()
216 hdw->cmd_buffer,1, in i2c_24xxx_ir()
217 hdw->cmd_buffer,4); in i2c_24xxx_ir()
218 dat[0] = hdw->cmd_buffer[0]; in i2c_24xxx_ir()
219 dat[1] = hdw->cmd_buffer[1]; in i2c_24xxx_ir()
220 dat[2] = hdw->cmd_buffer[2]; in i2c_24xxx_ir()
221 dat[3] = hdw->cmd_buffer[3]; in i2c_24xxx_ir()
222 } while (0); LOCK_GIVE(hdw->ctl_lock); in i2c_24xxx_ir()
255 static int i2c_hack_wm8775(struct pvr2_hdw *hdw, in i2c_hack_wm8775() argument
262 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); in i2c_hack_wm8775()
268 static int i2c_black_hole(struct pvr2_hdw *hdw, in i2c_black_hole() argument
281 static int i2c_hack_cx25840(struct pvr2_hdw *hdw, in i2c_hack_cx25840() argument
287 int state = hdw->i2c_cx25840_hack_state; in i2c_hack_cx25840()
297 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); in i2c_hack_cx25840()
332 ret = pvr2_i2c_basic_op(hdw,i2c_addr,wbuf,2,rdata,rlen); in i2c_hack_cx25840()
342 hdw->i2c_func[0x44] = NULL; in i2c_hack_cx25840()
343 pvr2_hdw_render_useless(hdw); in i2c_hack_cx25840()
352 hdw->i2c_cx25840_hack_state = state; in i2c_hack_cx25840()
356 hdw->i2c_cx25840_hack_state = state; in i2c_hack_cx25840()
368 struct pvr2_hdw *hdw = (struct pvr2_hdw *)(i2c_adap->algo_data); in pvr2_i2c_xfer() local
375 funcp = hdw->i2c_func[msgs[0].addr]; in pvr2_i2c_xfer()
388 if (funcp(hdw,msgs[0].addr,NULL,0,NULL,0)) { in pvr2_i2c_xfer()
402 if (bcnt > sizeof(hdw->cmd_buffer)-1) { in pvr2_i2c_xfer()
403 bcnt = sizeof(hdw->cmd_buffer)-1; in pvr2_i2c_xfer()
405 if (funcp(hdw,msgs[0].addr,NULL,0, in pvr2_i2c_xfer()
418 if (funcp(hdw,msgs[0].addr, in pvr2_i2c_xfer()
442 if (bcnt > sizeof(hdw->cmd_buffer)-1) { in pvr2_i2c_xfer()
443 bcnt = sizeof(hdw->cmd_buffer)-1; in pvr2_i2c_xfer()
445 if (funcp(hdw,msgs[0].addr, in pvr2_i2c_xfer()
517 static int do_i2c_probe(struct pvr2_hdw *hdw, int addr) in do_i2c_probe() argument
526 rc = i2c_transfer(&hdw->i2c_adap, msg, ARRAY_SIZE(msg)); in do_i2c_probe()
530 static void do_i2c_scan(struct pvr2_hdw *hdw) in do_i2c_scan() argument
533 pr_info("%s: i2c scan beginning\n", hdw->name); in do_i2c_scan()
535 if (do_i2c_probe(hdw, i)) { in do_i2c_scan()
537 hdw->name, i); in do_i2c_scan()
540 pr_info("%s: i2c scan done.\n", hdw->name); in do_i2c_scan()
543 static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw) in pvr2_i2c_register_ir() argument
546 struct IR_i2c_init_data *init_data = &hdw->ir_init_data; in pvr2_i2c_register_ir()
553 switch (hdw->ir_scheme_active) { in pvr2_i2c_register_ir()
559 init_data->name = hdw->hdw_desc->description; in pvr2_i2c_register_ir()
567 i2c_new_client_device(&hdw->i2c_adap, &info); in pvr2_i2c_register_ir()
575 init_data->name = hdw->hdw_desc->description; in pvr2_i2c_register_ir()
582 i2c_new_client_device(&hdw->i2c_adap, &info); in pvr2_i2c_register_ir()
591 void pvr2_i2c_core_init(struct pvr2_hdw *hdw) in pvr2_i2c_core_init() argument
598 hdw->i2c_func[idx] = pvr2_i2c_basic_op; in pvr2_i2c_core_init()
602 if (ir_mode[hdw->unit_number] == 0) { in pvr2_i2c_core_init()
603 pr_info("%s: IR disabled\n", hdw->name); in pvr2_i2c_core_init()
604 hdw->i2c_func[0x18] = i2c_black_hole; in pvr2_i2c_core_init()
605 } else if (ir_mode[hdw->unit_number] == 1) { in pvr2_i2c_core_init()
606 if (hdw->ir_scheme_active == PVR2_IR_SCHEME_24XXX) { in pvr2_i2c_core_init()
609 hdw->i2c_func[0x18] = i2c_24xxx_ir; in pvr2_i2c_core_init()
612 if (hdw->hdw_desc->flag_has_cx25840) { in pvr2_i2c_core_init()
613 hdw->i2c_func[0x44] = i2c_hack_cx25840; in pvr2_i2c_core_init()
615 if (hdw->hdw_desc->flag_has_wm8775) { in pvr2_i2c_core_init()
616 hdw->i2c_func[0x1b] = i2c_hack_wm8775; in pvr2_i2c_core_init()
620 hdw->i2c_adap = pvr2_i2c_adap_template; in pvr2_i2c_core_init()
621 hdw->i2c_algo = pvr2_i2c_algo_template; in pvr2_i2c_core_init()
622 strscpy(hdw->i2c_adap.name, hdw->name, sizeof(hdw->i2c_adap.name)); in pvr2_i2c_core_init()
623 hdw->i2c_adap.dev.parent = &hdw->usb_dev->dev; in pvr2_i2c_core_init()
624 hdw->i2c_adap.algo = &hdw->i2c_algo; in pvr2_i2c_core_init()
625 hdw->i2c_adap.algo_data = hdw; in pvr2_i2c_core_init()
626 hdw->i2c_linked = !0; in pvr2_i2c_core_init()
627 i2c_set_adapdata(&hdw->i2c_adap, &hdw->v4l2_dev); in pvr2_i2c_core_init()
628 i2c_add_adapter(&hdw->i2c_adap); in pvr2_i2c_core_init()
629 if (hdw->i2c_func[0x18] == i2c_24xxx_ir) { in pvr2_i2c_core_init()
636 if (do_i2c_probe(hdw, 0x71)) { in pvr2_i2c_core_init()
639 hdw->i2c_func[0x18] = NULL; in pvr2_i2c_core_init()
641 hdw->ir_scheme_active = PVR2_IR_SCHEME_24XXX_MCE; in pvr2_i2c_core_init()
644 if (i2c_scan) do_i2c_scan(hdw); in pvr2_i2c_core_init()
646 pvr2_i2c_register_ir(hdw); in pvr2_i2c_core_init()
649 void pvr2_i2c_core_done(struct pvr2_hdw *hdw) in pvr2_i2c_core_done() argument
651 if (hdw->i2c_linked) { in pvr2_i2c_core_done()
652 i2c_del_adapter(&hdw->i2c_adap); in pvr2_i2c_core_done()
653 hdw->i2c_linked = 0; in pvr2_i2c_core_done()