tag | line | file | source code |
cd | 129 | drivers/cdrom/cm206.c | #define stats(i) ++cd->stats[st_ ## i]; \ |
cd | 130 | drivers/cdrom/cm206.c | cd->last_stat[st_ ## i] = cd->stat_counter++; |
cd | 179 | drivers/cdrom/cm206.c | #define DISC_STATUS cd->disc_status[0] |
cd | 180 | drivers/cdrom/cm206.c | #define FIRST_TRACK cd->disc_status[1] |
cd | 181 | drivers/cdrom/cm206.c | #define LAST_TRACK cd->disc_status[2] |
cd | 182 | drivers/cdrom/cm206.c | #define PAUSED cd->audio_status[0] /* misuse this memory byte! */ |
cd | 183 | drivers/cdrom/cm206.c | #define PLAY_TO cd->toc[0] /* toc[0] records end-time in play */ |
cd | 185 | drivers/cdrom/cm206.c | static struct cm206_struct * cd; |
cd | 227 | drivers/cdrom/cm206.c | cd->intr_ds = inw(r_data_status); /* resets data_ready, data_error, |
cd | 230 | drivers/cdrom/cm206.c | cd->intr_ls = inw(r_line_status); /* resets overrun bit */ |
cd | 232 | drivers/cdrom/cm206.c | if (cd->intr_ls & ls_receive_buffer_full) { |
cd | 233 | drivers/cdrom/cm206.c | cd->intr_ur = inb(r_uart_receive); /* get order right! */ |
cd | 234 | drivers/cdrom/cm206.c | cd->intr_ls = inw(r_line_status); /* resets rbf interrupt */ |
cd | 235 | drivers/cdrom/cm206.c | if (!cd->background && cd->uart) wake_up_interruptible(&cd->uart); |
cd | 238 | drivers/cdrom/cm206.c | else if (cd->intr_ds & ds_data_ready) { |
cd | 239 | drivers/cdrom/cm206.c | if (cd->background) ++cd->adapter_last; |
cd | 240 | drivers/cdrom/cm206.c | if ((cd->wait_back || !cd->background) && cd->data) |
cd | 241 | drivers/cdrom/cm206.c | wake_up_interruptible(&cd->data); |
cd | 245 | drivers/cdrom/cm206.c | else if (cd->command && cd->intr_ls & ls_transmitter_buffer_empty) { |
cd | 247 | drivers/cdrom/cm206.c | outw(cd->command, r_uart_transmit); |
cd | 248 | drivers/cdrom/cm206.c | cd->command=0; |
cd | 249 | drivers/cdrom/cm206.c | if (!cd->background) wake_up_interruptible(&cd->uart); |
cd | 252 | drivers/cdrom/cm206.c | else if (cd->intr_ds & ds_fifo_overflow) { |
cd | 253 | drivers/cdrom/cm206.c | debug(("Fifo overflow at sectors 0x%x\n", cd->sector_first)); |
cd | 255 | drivers/cdrom/cm206.c | cd->fifo_overflowed=1; /* signal one word less should be read */ |
cd | 258 | drivers/cdrom/cm206.c | else if (cd->intr_ds & ds_data_error) { |
cd | 259 | drivers/cdrom/cm206.c | debug(("Data error at sector 0x%x\n", cd->sector_first)); |
cd | 262 | drivers/cdrom/cm206.c | else if (cd->intr_ds & ds_crc_error) { |
cd | 263 | drivers/cdrom/cm206.c | debug(("CRC error at sector 0x%x\n", cd->sector_first)); |
cd | 266 | drivers/cdrom/cm206.c | else if (cd->intr_ds & ds_sync_error) { |
cd | 267 | drivers/cdrom/cm206.c | debug(("Sync at sector 0x%x\n", cd->sector_first)); |
cd | 270 | drivers/cdrom/cm206.c | else if (cd->intr_ds & ds_toc_ready) { |
cd | 278 | drivers/cdrom/cm206.c | if (cd->background && (cd->adapter_last-cd->adapter_first == cd->max_sectors |
cd | 279 | drivers/cdrom/cm206.c | || cd->fifo_overflowed)) |
cd | 287 | drivers/cdrom/cm206.c | cd->timed_out = 1; |
cd | 295 | drivers/cdrom/cm206.c | cd->timer.data=(unsigned long) wait; |
cd | 296 | drivers/cdrom/cm206.c | cd->timer.expires = jiffies + timeout; |
cd | 297 | drivers/cdrom/cm206.c | add_timer(&cd->timer); |
cd | 299 | drivers/cdrom/cm206.c | del_timer(&cd->timer); |
cd | 300 | drivers/cdrom/cm206.c | if (cd->timed_out) { |
cd | 301 | drivers/cdrom/cm206.c | cd->timed_out = 0; |
cd | 316 | drivers/cdrom/cm206.c | cd->command = command; |
cd | 321 | drivers/cdrom/cm206.c | if (sleep_or_timeout(&cd->uart, UART_TIMEOUT)) { |
cd | 333 | drivers/cdrom/cm206.c | sleep_or_timeout(&cd->uart, UART_TIMEOUT)) { |
cd | 338 | drivers/cdrom/cm206.c | return cd->intr_ur; |
cd | 350 | drivers/cdrom/cm206.c | sleep_or_timeout(&cd->uart, DSB_TIMEOUT)) { |
cd | 355 | drivers/cdrom/cm206.c | return cd->intr_ur; |
cd | 367 | drivers/cdrom/cm206.c | cd->dsb = wait_dsb(); /* wait for command to finish */ |
cd | 441 | drivers/cdrom/cm206.c | if (cd->background) return -1; /* can't do twice */ |
cd | 444 | drivers/cdrom/cm206.c | cd->adapter_first = cd->adapter_last = start; |
cd | 445 | drivers/cdrom/cm206.c | cd->background = 1; /* flag a read is going on */ |
cd | 451 | drivers/cdrom/cm206.c | if (cd->background) { |
cd | 452 | drivers/cdrom/cm206.c | cd->background=0; |
cd | 453 | drivers/cdrom/cm206.c | cd->adapter_last = -1; /* invalidate adapter memory */ |
cd | 456 | drivers/cdrom/cm206.c | cd->fifo_overflowed=0; |
cd | 459 | drivers/cdrom/cm206.c | if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) { |
cd | 465 | drivers/cdrom/cm206.c | insw(r_fifo_output_buffer, cd->sector, READ_AHEAD*RAW_SECTOR_SIZE/2); |
cd | 467 | drivers/cdrom/cm206.c | cd->sector_first = start; cd->sector_last = start+READ_AHEAD; |
cd | 484 | drivers/cdrom/cm206.c | debug(("bh: %d\n", cd->background)); |
cd | 485 | drivers/cdrom/cm206.c | switch (cd->background) { |
cd | 488 | drivers/cdrom/cm206.c | if (!(cd->intr_ls & ls_transmitter_buffer_empty)) { |
cd | 489 | drivers/cdrom/cm206.c | cd->command = c_stop; |
cd | 492 | drivers/cdrom/cm206.c | cd->background=2; |
cd | 499 | drivers/cdrom/cm206.c | cd->background=3; |
cd | 502 | drivers/cdrom/cm206.c | if (cd->intr_ur != c_stop) { |
cd | 503 | drivers/cdrom/cm206.c | debug(("cm206_bh: c_stop echoed 0x%x\n", cd->intr_ur)); |
cd | 506 | drivers/cdrom/cm206.c | cd->background++; |
cd | 509 | drivers/cdrom/cm206.c | if (cd->intr_ur != 0xff) { |
cd | 510 | drivers/cdrom/cm206.c | debug(("cm206_bh: c_stop reacted with 0x%x\n", cd->intr_ur)); |
cd | 513 | drivers/cdrom/cm206.c | cd->background=0; |
cd | 521 | drivers/cdrom/cm206.c | cd->dsb=status[0]; |
cd | 522 | drivers/cdrom/cm206.c | cd->cc=status[1]; |
cd | 527 | drivers/cdrom/cm206.c | if (type_1_command(c_disc_status, 7, cd->disc_status)) { |
cd | 534 | drivers/cdrom/cm206.c | if (!cd->openfiles) { |
cd | 535 | drivers/cdrom/cm206.c | cd->background=0; |
cd | 537 | drivers/cdrom/cm206.c | cd->adapter_last = -1; /* invalidate adapter memory */ |
cd | 538 | drivers/cdrom/cm206.c | cd->sector_last = -1; |
cd | 540 | drivers/cdrom/cm206.c | if (cd->dsb & dsb_tray_not_closed) { |
cd | 543 | drivers/cdrom/cm206.c | while (i++<10 && cd->dsb & dsb_drive_not_ready) { |
cd | 548 | drivers/cdrom/cm206.c | if (cd->dsb & (dsb_not_useful)) return -EIO; |
cd | 549 | drivers/cdrom/cm206.c | if (!(cd->dsb & dsb_disc_present)) return -ENODATA; |
cd | 550 | drivers/cdrom/cm206.c | if (cd->dsb & dsb_possible_media_change) { |
cd | 551 | drivers/cdrom/cm206.c | memset(cd->toc, 0, sizeof(cd->toc)); |
cd | 552 | drivers/cdrom/cm206.c | memset(cd->audio_status, 0, sizeof(cd->audio_status)); |
cd | 556 | drivers/cdrom/cm206.c | if (!(cd->dsb & dsb_tray_locked)) { |
cd | 564 | drivers/cdrom/cm206.c | ++cd->openfiles; MOD_INC_USE_COUNT; |
cd | 571 | drivers/cdrom/cm206.c | if (cd->openfiles==1) { |
cd | 572 | drivers/cdrom/cm206.c | if (cd->background) { |
cd | 573 | drivers/cdrom/cm206.c | cd->background=0; |
cd | 577 | drivers/cdrom/cm206.c | cd->sector_last = -1; /* Make our internal buffer invalid */ |
cd | 582 | drivers/cdrom/cm206.c | --cd->openfiles; MOD_DEC_USE_COUNT; |
cd | 590 | drivers/cdrom/cm206.c | insw(r_fifo_output_buffer, cd->sector + cd->fifo_overflowed, |
cd | 591 | drivers/cdrom/cm206.c | RAW_SECTOR_SIZE/2 - cd->fifo_overflowed); |
cd | 593 | drivers/cdrom/cm206.c | ++cd->adapter_first; /* update the current adapter sector */ |
cd | 594 | drivers/cdrom/cm206.c | cd->fifo_overflowed=0; /* reset overflow bit */ |
cd | 597 | drivers/cdrom/cm206.c | cd->sector_first=cd->adapter_first-1; |
cd | 598 | drivers/cdrom/cm206.c | cd->sector_last=cd->adapter_first; /* update the buffer sector */ |
cd | 606 | drivers/cdrom/cm206.c | if (cd->adapter_first <= sector && sector < cd->adapter_last) { |
cd | 608 | drivers/cdrom/cm206.c | empty_buffer(sector - cd->adapter_first); |
cd | 611 | drivers/cdrom/cm206.c | else if (cd->background==1 && cd->adapter_first <= sector |
cd | 612 | drivers/cdrom/cm206.c | && sector < cd->adapter_first+cd->max_sectors) { |
cd | 614 | drivers/cdrom/cm206.c | cd->wait_back=1; |
cd | 615 | drivers/cdrom/cm206.c | while (sector >= cd->adapter_last) { |
cd | 616 | drivers/cdrom/cm206.c | if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) { |
cd | 618 | drivers/cdrom/cm206.c | cd->adapter_last, cd->adapter_first, cd->background)); |
cd | 620 | drivers/cdrom/cm206.c | cd->wait_back=0; |
cd | 624 | drivers/cdrom/cm206.c | cd->wait_back=0; |
cd | 625 | drivers/cdrom/cm206.c | empty_buffer(sector - cd->adapter_first); |
cd | 655 | drivers/cdrom/cm206.c | if (cd->sector_first <= cd_sec_no && cd_sec_no < cd->sector_last) { |
cd | 656 | drivers/cdrom/cm206.c | source = ((uch *) cd->sector) + 16 + |
cd | 657 | drivers/cdrom/cm206.c | quarter*512 + (cd_sec_no-cd->sector_first)*RAW_SECTOR_SIZE; |
cd | 661 | drivers/cdrom/cm206.c | source = ((uch *) cd->sector)+16+quarter*512; |
cd | 678 | drivers/cdrom/cm206.c | mssp->addr.lba = fsm2lba(&cd->disc_status[3]); |
cd | 680 | drivers/cdrom/cm206.c | mssp->addr.msf.frame = cd->disc_status[3]; |
cd | 681 | drivers/cdrom/cm206.c | mssp->addr.msf.second = cd->disc_status[4]; |
cd | 682 | drivers/cdrom/cm206.c | mssp->addr.msf.minute = cd->disc_status[5]; |
cd | 714 | drivers/cdrom/cm206.c | cd->dsb = wait_dsb(); |
cd | 736 | drivers/cdrom/cm206.c | uch * q = cd->q; |
cd | 741 | drivers/cdrom/cm206.c | for (i=track; i>0; i--) if (cd->toc[i].track) { |
cd | 742 | drivers/cdrom/cm206.c | min = fsm2lba(cd->toc[i].fsm); |
cd | 750 | drivers/cdrom/cm206.c | if (!cd->toc[ct].track) { |
cd | 753 | drivers/cdrom/cm206.c | cd->toc[ct].track=q[1]; /* lead out still 0xaa */ |
cd | 754 | drivers/cdrom/cm206.c | fsm(l, cd->toc[ct].fsm); |
cd | 755 | drivers/cdrom/cm206.c | cd->toc[ct].q0 = q[0]; /* contains adr and ctrl info */ |
cd | 782 | drivers/cdrom/cm206.c | if (!cd->toc[track].track) get_toc_lba(track); |
cd | 792 | drivers/cdrom/cm206.c | cd->toc[1].track=1; /* fill in first track position */ |
cd | 793 | drivers/cdrom/cm206.c | for (i=0; i<3; i++) cd->toc[1].fsm[i] = cd->disc_status[3+i]; |
cd | 810 | drivers/cdrom/cm206.c | cd->dsb = wait_dsb(); |
cd | 820 | drivers/cdrom/cm206.c | play_command[i+1] = cd->audio_status[i+2]; |
cd | 826 | drivers/cdrom/cm206.c | play_command[i+1] = cd->toc[from].fsm[i]; |
cd | 827 | drivers/cdrom/cm206.c | PLAY_TO.fsm[i] = play_command[i+4] = cd->toc[to+1].fsm[i]; |
cd | 833 | drivers/cdrom/cm206.c | cd->dsb = wait_dsb(); |
cd | 839 | drivers/cdrom/cm206.c | uch * q = cd->q; |
cd | 857 | drivers/cdrom/cm206.c | if (cd->dsb & dsb_play_in_progress) |
cd | 870 | drivers/cdrom/cm206.c | ep->cdte_addr.msf.frame = cd->toc[track].fsm[0]; |
cd | 871 | drivers/cdrom/cm206.c | ep->cdte_addr.msf.second = cd->toc[track].fsm[1]; |
cd | 872 | drivers/cdrom/cm206.c | ep->cdte_addr.msf.minute = cd->toc[track].fsm[2]; |
cd | 874 | drivers/cdrom/cm206.c | else ep->cdte_addr.lba = fsm2lba(cd->toc[track].fsm); |
cd | 875 | drivers/cdrom/cm206.c | ep->cdte_adr = cd->toc[track].q0 & 0xf; |
cd | 876 | drivers/cdrom/cm206.c | ep->cdte_ctrl = cd->toc[track].q0 >> 4; |
cd | 892 | drivers/cdrom/cm206.c | else return cd->stats[arg]; |
cd | 895 | drivers/cdrom/cm206.c | else return cd->last_stat[arg]; |
cd | 918 | drivers/cdrom/cm206.c | cd->sector_last = -1; /* flag no data buffered */ |
cd | 919 | drivers/cdrom/cm206.c | cd->adapter_last = -1; |
cd | 924 | drivers/cdrom/cm206.c | if (cd->dsb & (dsb_drive_not_ready | dsb_tray_not_closed) ) |
cd | 973 | drivers/cdrom/cm206.c | if (cd->dsb & dsb_play_in_progress) return type_0_command(c_stop, 1); |
cd | 976 | drivers/cdrom/cm206.c | if (cd->dsb & dsb_play_in_progress) { |
cd | 978 | drivers/cdrom/cm206.c | type_1_command(c_audio_status, 5, cd->audio_status); |
cd | 988 | drivers/cdrom/cm206.c | if (cd->openfiles == 1) { /* Must do an open before an eject! */ |
cd | 990 | drivers/cdrom/cm206.c | memset(cd->toc, 0, sizeof(cd->toc)); |
cd | 991 | drivers/cdrom/cm206.c | memset(cd->disc_status, 0, sizeof(cd->disc_status)); |
cd | 1058 | drivers/cdrom/cm206.c | kfree(cd); |
cd | 1130 | drivers/cdrom/cm206.c | cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL); |
cd | 1131 | drivers/cdrom/cm206.c | if (!cd) return -EIO; |
cd | 1174 | drivers/cdrom/cm206.c | memset(cd, 0, sizeof(*cd)); /* give'm some reasonable value */ |
cd | 1175 | drivers/cdrom/cm206.c | cd->sector_last = -1; /* flag no data buffered */ |
cd | 1176 | drivers/cdrom/cm206.c | cd->adapter_last = -1; |
cd | 1177 | drivers/cdrom/cm206.c | cd->timer.function = cm206_timeout; |
cd | 1178 | drivers/cdrom/cm206.c | cd->max_sectors = (inw(r_data_status) & ds_ram_size) ? 24 : 97; |
cd | 1180 | drivers/cdrom/cm206.c | " %ld bytes kernel memory used.\n", cd->max_sectors*2, size); |