Deleted Added
full compact
mcd.c (13598) mcd.c (13732)
1/*
2 * Copyright 1993 by Holger Veit (data part)
3 * Copyright 1993 by Brian Moore (audio part)
4 * Changes Copyright 1993 by Gary Clark II
5 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia
6 *
7 * Rewrote probe routine to work on newer Mitsumi drives.
8 * Additional changes (C) 1994 by Jordan K. Hubbard

--- 26 unchanged lines hidden (view full) ---

35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
1/*
2 * Copyright 1993 by Holger Veit (data part)
3 * Copyright 1993 by Brian Moore (audio part)
4 * Changes Copyright 1993 by Gary Clark II
5 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia
6 *
7 * Rewrote probe routine to work on newer Mitsumi drives.
8 * Additional changes (C) 1994 by Jordan K. Hubbard

--- 26 unchanged lines hidden (view full) ---

35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
43 * $Id: mcd.c,v 1.58 1996/01/15 10:28:29 phk Exp $
43 * $Id: mcd.c,v 1.59 1996/01/23 22:55:08 joerg Exp $
44 */
45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
46
47#include "mcd.h"
48#if NMCD > 0
49#include <sys/types.h>
50#include <sys/param.h>
51#include <sys/systm.h>

--- 1343 unchanged lines hidden (view full) ---

1395 if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
1396 return EIO;
1397
1398 if (trk != 0)
1399 return ENXIO;
1400
1401 /* add a fake last+1 */
1402 idx = th.ending_track + 1;
44 */
45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
46
47#include "mcd.h"
48#if NMCD > 0
49#include <sys/types.h>
50#include <sys/param.h>
51#include <sys/systm.h>

--- 1343 unchanged lines hidden (view full) ---

1395 if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
1396 return EIO;
1397
1398 if (trk != 0)
1399 return ENXIO;
1400
1401 /* add a fake last+1 */
1402 idx = th.ending_track + 1;
1403 cd->toc[idx].ctrl_adr = cd->toc[idx-1].ctrl_adr;
1403 cd->toc[idx].control = cd->toc[idx-1].control;
1404 cd->toc[idx].addr_type = cd->toc[idx-1].addr_type;
1404 cd->toc[idx].trk_no = 0;
1405 cd->toc[idx].trk_no = 0;
1405 cd->toc[idx].idx_no = 0xAA;
1406 cd->toc[idx].idx_no = MCD_LASTPLUS1;
1406 cd->toc[idx].hd_pos_msf[0] = cd->volinfo.vol_msf[0];
1407 cd->toc[idx].hd_pos_msf[1] = cd->volinfo.vol_msf[1];
1408 cd->toc[idx].hd_pos_msf[2] = cd->volinfo.vol_msf[2];
1409
1410 if (cd->debug)
1411 { int i;
1412 for (i = th.starting_track; i <= idx; i++)
1413 printf("mcd%d: trk %d idx %d pos %d %d %d\n",
1414 unit, i,
1407 cd->toc[idx].hd_pos_msf[0] = cd->volinfo.vol_msf[0];
1408 cd->toc[idx].hd_pos_msf[1] = cd->volinfo.vol_msf[1];
1409 cd->toc[idx].hd_pos_msf[2] = cd->volinfo.vol_msf[2];
1410
1411 if (cd->debug)
1412 { int i;
1413 for (i = th.starting_track; i <= idx; i++)
1414 printf("mcd%d: trk %d idx %d pos %d %d %d\n",
1415 unit, i,
1415 cd->toc[i].idx_no,
1416 cd->toc[i].idx_no > 0x99 ? cd->toc[i].idx_no :
1417 bcd2bin(cd->toc[i].idx_no),
1416 bcd2bin(cd->toc[i].hd_pos_msf[0]),
1417 bcd2bin(cd->toc[i].hd_pos_msf[1]),
1418 bcd2bin(cd->toc[i].hd_pos_msf[2]));
1419 }
1420
1421 cd->flags |= MCDTOC;
1422
1423 return 0;
1424}
1425
1426static int
1427mcd_toc_entrys(int unit, struct ioc_read_toc_entry *te)
1428{
1429 struct mcd_data *cd = mcd_data + unit;
1430 struct cd_toc_entry entries[MCD_MAXTOCS];
1431 struct ioc_toc_header th;
1418 bcd2bin(cd->toc[i].hd_pos_msf[0]),
1419 bcd2bin(cd->toc[i].hd_pos_msf[1]),
1420 bcd2bin(cd->toc[i].hd_pos_msf[2]));
1421 }
1422
1423 cd->flags |= MCDTOC;
1424
1425 return 0;
1426}
1427
1428static int
1429mcd_toc_entrys(int unit, struct ioc_read_toc_entry *te)
1430{
1431 struct mcd_data *cd = mcd_data + unit;
1432 struct cd_toc_entry entries[MCD_MAXTOCS];
1433 struct ioc_toc_header th;
1432 int rc, i, len = te->data_len;
1434 int rc, n, trk, len = te->data_len;
1433
1435
1434 /* Make sure we have a valid toc */
1435 if ((rc=mcd_read_toc(unit)) != 0)
1436 return rc;
1437
1438 /* find the toc to copy*/
1439 i = te->starting_track;
1440 if (i == MCD_LASTPLUS1)
1441 i = bcd2bin(cd->volinfo.trk_high) + 1;
1442
1443 /* verify starting track */
1444 if (i < bcd2bin(cd->volinfo.trk_low) ||
1445 i > bcd2bin(cd->volinfo.trk_high)+1) {
1446 return EINVAL;
1447 }
1448
1449 /* do we have room */
1450 if ( len > sizeof(entries)
1451 || len < sizeof(struct cd_toc_entry)
1452 || (len % sizeof(struct cd_toc_entry)) != 0
1453 )
1454 return EINVAL;
1436 if ( len > sizeof(entries)
1437 || len < sizeof(struct cd_toc_entry)
1438 || (len % sizeof(struct cd_toc_entry)) != 0
1439 )
1440 return EINVAL;
1441 if (te->address_format != CD_MSF_FORMAT &&
1442 te->address_format != CD_LBA_FORMAT)
1443 return EINVAL;
1455
1456 /* Copy the toc header */
1457 if ((rc = mcd_toc_header(unit, &th)) != 0)
1458 return rc;
1459
1444
1445 /* Copy the toc header */
1446 if ((rc = mcd_toc_header(unit, &th)) != 0)
1447 return rc;
1448
1460 do {
1461 /* copy the toc data */
1462 entries[i-1].control = cd->toc[i].ctrl_adr;
1463 entries[i-1].addr_type = te->address_format;
1464 entries[i-1].track = i;
1465 if (te->address_format == CD_MSF_FORMAT) {
1466 entries[i-1].addr.msf.unused = 0;
1467 entries[i-1].addr.msf.minute = bcd2bin(cd->toc[i].hd_pos_msf[0]);
1468 entries[i-1].addr.msf.second = bcd2bin(cd->toc[i].hd_pos_msf[1]);
1469 entries[i-1].addr.msf.frame = bcd2bin(cd->toc[i].hd_pos_msf[2]);
1449 /* verify starting track */
1450 trk = te->starting_track;
1451 if (trk == 0)
1452 trk = th.starting_track;
1453 else if (trk == MCD_LASTPLUS1)
1454 trk = th.ending_track + 1;
1455 else if (trk < th.starting_track || trk > th.ending_track + 1)
1456 return EINVAL;
1457
1458 /* Make sure we have a valid toc */
1459 if ((rc=mcd_read_toc(unit)) != 0)
1460 return rc;
1461
1462 /* Copy the TOC data. */
1463 for (n = 0; len > 0 && trk <= th.ending_track + 1; trk++) {
1464 if (cd->toc[trk].idx_no == 0)
1465 continue;
1466 entries[n].control = cd->toc[trk].control;
1467 entries[n].addr_type = cd->toc[trk].addr_type;
1468 entries[n].track =
1469 cd->toc[trk].idx_no > 0x99 ? cd->toc[trk].idx_no :
1470 bcd2bin(cd->toc[trk].idx_no);
1471 switch (te->address_format) {
1472 case CD_MSF_FORMAT:
1473 entries[n].addr.msf.unused = 0;
1474 entries[n].addr.msf.minute = bcd2bin(cd->toc[trk].hd_pos_msf[0]);
1475 entries[n].addr.msf.second = bcd2bin(cd->toc[trk].hd_pos_msf[1]);
1476 entries[n].addr.msf.frame = bcd2bin(cd->toc[trk].hd_pos_msf[2]);
1477 break;
1478 case CD_LBA_FORMAT:
1479 entries[n].addr.lba = msf2hsg(cd->toc[trk].hd_pos_msf);
1480 break;
1470 }
1471 len -= sizeof(struct cd_toc_entry);
1481 }
1482 len -= sizeof(struct cd_toc_entry);
1472 i++;
1483 n++;
1473 }
1484 }
1474 while (len > 0 && i <= th.ending_track + 2);
1475
1476 /* copy the data back */
1485
1486 /* copy the data back */
1477 if (copyout(entries, te->data, (i - 1) * sizeof(struct cd_toc_entry)) != 0)
1478 return EFAULT;
1479
1480 return 0;
1487 return copyout(entries, te->data, n * sizeof(struct cd_toc_entry));
1481}
1482
1483static int
1484mcd_stop(int unit)
1485{
1486 struct mcd_data *cd = mcd_data + unit;
1487
1488 /* Verify current status */

--- 15 unchanged lines hidden (view full) ---

1504{
1505 struct mcd_data *cd = mcd_data + unit;
1506
1507 if (mcd_send(unit, MCD_CMDGETQCHN, MCD_RETRYS) < 0)
1508 return -1;
1509 if (mcd_get(unit, (char *) q, sizeof(struct mcd_qchninfo)) < 0)
1510 return -1;
1511 if (cd->debug) {
1488}
1489
1490static int
1491mcd_stop(int unit)
1492{
1493 struct mcd_data *cd = mcd_data + unit;
1494
1495 /* Verify current status */

--- 15 unchanged lines hidden (view full) ---

1511{
1512 struct mcd_data *cd = mcd_data + unit;
1513
1514 if (mcd_send(unit, MCD_CMDGETQCHN, MCD_RETRYS) < 0)
1515 return -1;
1516 if (mcd_get(unit, (char *) q, sizeof(struct mcd_qchninfo)) < 0)
1517 return -1;
1518 if (cd->debug) {
1512 printf("mcd%d: getqchan ctrl_adr=0x%x trk=%d ind=%d ttm=%d:%d.%d dtm=%d:%d.%d\n",
1519 printf("mcd%d: getqchan control=0x%x addr_type=0x%x trk=%d ind=%d ttm=%d:%d.%d dtm=%d:%d.%d\n",
1513 unit,
1520 unit,
1514 q->ctrl_adr, bcd2bin(q->trk_no), bcd2bin(q->idx_no),
1521 q->control, q->addr_type, bcd2bin(q->trk_no),
1522 bcd2bin(q->idx_no),
1515 bcd2bin(q->trk_size_msf[0]), bcd2bin(q->trk_size_msf[1]),
1516 bcd2bin(q->trk_size_msf[2]),
1517 bcd2bin(q->hd_pos_msf[0]), bcd2bin(q->hd_pos_msf[1]),
1518 bcd2bin(q->hd_pos_msf[2]));
1519 }
1520 return 0;
1521}
1522

--- 19 unchanged lines hidden (view full) ---

1542 if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
1543 return EIO;
1544
1545 if (mcd_getqchan(unit, &q) < 0)
1546 return EIO;
1547
1548 data.header.audio_status = cd->audio_status;
1549 data.what.position.data_format = CD_CURRENT_POSITION;
1523 bcd2bin(q->trk_size_msf[0]), bcd2bin(q->trk_size_msf[1]),
1524 bcd2bin(q->trk_size_msf[2]),
1525 bcd2bin(q->hd_pos_msf[0]), bcd2bin(q->hd_pos_msf[1]),
1526 bcd2bin(q->hd_pos_msf[2]));
1527 }
1528 return 0;
1529}
1530

--- 19 unchanged lines hidden (view full) ---

1550 if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
1551 return EIO;
1552
1553 if (mcd_getqchan(unit, &q) < 0)
1554 return EIO;
1555
1556 data.header.audio_status = cd->audio_status;
1557 data.what.position.data_format = CD_CURRENT_POSITION;
1550 data.what.position.addr_type = q.ctrl_adr;
1551 data.what.position.control = q.ctrl_adr >> 4;
1558 data.what.position.control = q.control;
1559 data.what.position.addr_type = q.addr_type;
1552 data.what.position.track_number = bcd2bin(q.trk_no);
1553 data.what.position.index_number = bcd2bin(q.idx_no);
1560 data.what.position.track_number = bcd2bin(q.trk_no);
1561 data.what.position.index_number = bcd2bin(q.idx_no);
1554 if (sc->address_format == CD_MSF_FORMAT) {
1562 switch (sc->address_format) {
1563 case CD_MSF_FORMAT:
1555 data.what.position.reladdr.msf.unused = 0;
1556 data.what.position.reladdr.msf.minute = bcd2bin(q.trk_size_msf[0]);
1557 data.what.position.reladdr.msf.second = bcd2bin(q.trk_size_msf[1]);
1558 data.what.position.reladdr.msf.frame = bcd2bin(q.trk_size_msf[2]);
1559 data.what.position.absaddr.msf.unused = 0;
1560 data.what.position.absaddr.msf.minute = bcd2bin(q.hd_pos_msf[0]);
1561 data.what.position.absaddr.msf.second = bcd2bin(q.hd_pos_msf[1]);
1562 data.what.position.absaddr.msf.frame = bcd2bin(q.hd_pos_msf[2]);
1564 data.what.position.reladdr.msf.unused = 0;
1565 data.what.position.reladdr.msf.minute = bcd2bin(q.trk_size_msf[0]);
1566 data.what.position.reladdr.msf.second = bcd2bin(q.trk_size_msf[1]);
1567 data.what.position.reladdr.msf.frame = bcd2bin(q.trk_size_msf[2]);
1568 data.what.position.absaddr.msf.unused = 0;
1569 data.what.position.absaddr.msf.minute = bcd2bin(q.hd_pos_msf[0]);
1570 data.what.position.absaddr.msf.second = bcd2bin(q.hd_pos_msf[1]);
1571 data.what.position.absaddr.msf.frame = bcd2bin(q.hd_pos_msf[2]);
1563 } else if (sc->address_format == CD_LBA_FORMAT) {
1572 break;
1573 case CD_LBA_FORMAT:
1564 data.what.position.reladdr.lba = msf2hsg(q.trk_size_msf);
1565 data.what.position.absaddr.lba = msf2hsg(q.hd_pos_msf);
1574 data.what.position.reladdr.lba = msf2hsg(q.trk_size_msf);
1575 data.what.position.absaddr.lba = msf2hsg(q.hd_pos_msf);
1576 break;
1566 }
1567
1577 }
1578
1568 if (copyout(&data, sc->data, min(sizeof(struct cd_sub_channel_info), sc->data_len))!=0)
1569 return EFAULT;
1570 return 0;
1579 return copyout(&data, sc->data, min(sizeof(struct cd_sub_channel_info), sc->data_len));
1571}
1572
1573static int
1574mcd_playmsf(int unit, struct ioc_play_msf *pt)
1575{
1576 struct mcd_read2 pb;
1577
1578 if (mcd_setmode(unit, MCD_MD_COOKED) != 0)

--- 145 unchanged lines hidden ---
1580}
1581
1582static int
1583mcd_playmsf(int unit, struct ioc_play_msf *pt)
1584{
1585 struct mcd_read2 pb;
1586
1587 if (mcd_setmode(unit, MCD_MD_COOKED) != 0)

--- 145 unchanged lines hidden ---