static inline void i2s_clear_irqs(struct dw_i2s_dev *dev, u32 stream)
{
	u32 i = 0;

	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
		for (i = 0; i < 4; i++)
			i2s_read_reg(dev->i2s_base, TOR(i));
	} else {
		for (i = 0; i < 4; i++)
			i2s_read_reg(dev->i2s_base, ROR(i));
	}
}
Exemple #2
0
static edge_ref make_edge(void)
{
    edge_ref e;

    assert(e = (edge_ref) malloc(sizeof(edge_struct)));
    ONEXT(e) = e;
    ROTRNEXT(e) = TOR(e);
    SYMDNEXT(e) = SYM(e);
    TORLNEXT(e) = ROT(e);
    MARK(e) = 0;
    return e;
}
Exemple #3
0
/* This routine implements equation 16 on page 15, computing 
   pi super dh sub i j.  (dh is for dihedral.)
   We update the forces in info, so it can't be const.
*/
void BrennerPotential::calc_dihedral_terms(
		    int i, int j, int jn,
                    const struct AtomPairInfoState *apis,
                    /* xnt1 is N super t sub i. */
                    Float xnt1,
                    /* xnt2 is N super t sub j. */
                    Float xnt2,
                    /* conjug is N sub conj. */
                    Float conjug, Float sij,
                    Float *sink, Float *sinl, Float *dctik, Float *dctjk,
                    Float *dctil, Float *dctij, Float *dctjl, Float *dctji,
                    Float *cosk, Float *cosl, bren_vector cj,
                    Float vatt,
                    const bren_vector *xk, const bren_vector *xl,
                    /* btot will be the total energy, that is,
                       pi super dh sub i j. */ 
                    Float *btot,
                    /* dradi is returned as the partial of total energy with
                       respect to xnt1. */
                    Float *dradi,
                    /* dradj is returned as the partial of total energy with
                       respect to xnt2. */
                    Float *dradj,
                    /* drdc is returned as the partial of total energy with
                       respect to conjug. */
                    Float *drdc)
{
  /* k will be an index into the list of neighbors of i. */
  int k, nk;
  //  XXX The following neighbor list access should be optimized away
  int nmaxnb = nblist->MaxNeighborListLength();
  vector<int> iNeighbors(nmaxnb);
  vector<Vec> distances(nmaxnb);
  vector<double> sq_distances(nmaxnb);
  /* stop_index is one past the index of the last neighbor. */
  int sizemax = nmaxnb;
  const int stop_index =
    nblist->GetFullNeighbors(i, &iNeighbors[0], &distances[0],
			     &sq_distances[0], sizemax);

  const int *neighbor_start = &iNeighbors[0];
  const struct AtomPairInfo *iatom_pair = pairsconst (i, apis);
  Float dbtori = 0.0;
  Float dbtorj = 0.0;
  Float dbtorc = 0.0;
  Float btor = 0.0;
  Float datori,datorj ,datorc;
  Float ator = TOR(xnt1,xnt2,conjug,&datori,&datorj,&datorc);  // XXX
  Float vatt_ator = vatt*ator;

  if(fabs(ator) <= 1.0e-08) {
     return;
  }

  nk = 0;
  for(k = 0; k < stop_index; ++k) {
    Float sink2, rck, fck, dfck;
    bren_vector ck, cl, dt2djl;
    const bren_vector xk_nk = xk[nk+1];
    Float crkx, crky, crkz;
    int nl, l;
    int kn;
    Float cosk_nk;
    //const int *jneighbor_start;
    const struct AtomPairInfo *jatom_pair;
    if(k == j || iatom_pair[k].lcheck != 1) continue;
    ++nk;
    /* Used to have a bug here, cosk was getting set to cosk[nk] before we
       incremented nk. */
    cosk_nk = cosk[nk];
    if(fabs(sink[nk]) < 1.0e-01) continue;
    sink2 = sink[nk]*sink[nk];
    kn = neighbor_start[k];
    ck = iatom_pair[k].cor;
    crkx = ck[1]*cj[2]-cj[1]*ck[2];
    crky = ck[2]*cj[0]-cj[2]*ck[0];
    crkz = ck[0]*cj[1]-cj[0]*ck[1];
    dt2djl[0] = -cj[1]*crkz+cj[2]*crky;
    dt2djl[1] = -cj[2]*crkx+cj[0]*crkz;
    dt2djl[2] = -cj[0]*crky+cj[1]*crkx;

    rck = iatom_pair[k].rcor;

    if(getKtype(kn) == 2) {
      /* It's a hydrogen.  This is computing f super c sub i j from equation 18
       on page 16, but I don't know why we aren't using the table so
       laboriously precomputed for this purpose in mtable.c.  Tim Freeman  5
       Aug 2000. */
      fck = 1.0;
      dfck = 0.0;
      if(rck >= 1.60) continue;
      if(rck >= 1.30) {
        Float dtemp= PIDT*(rck-1.30);
        fck = (1.0+cos(dtemp))/2.0;
        dfck = -PIDT/2.0*sin(dtemp);
      }
    } else {
      fck = iatom_pair[k].ww;
      dfck = iatom_pair[k].dww;
    }
    //jneighbor_start = neighbors (jn, cans);
    //stop_index2 = numNeighbors (jn, cans);
    vector<int> jneighbor_start(nmaxnb);
    int sizemax = nmaxnb;
    const int stop_index2 =
      nblist->GetFullNeighbors(jn, &jneighbor_start[0], &distances[0],
			       &sq_distances[0], sizemax);
    jatom_pair = pairsconst (jn, apis);
    nl = 0;
    for(l = 0; l < stop_index2; ++l) {
      int ln = jneighbor_start[l];
      Float sinl2, rcl, t1, t2, cw, bt, fcl, dfcl;
      Float aa, aaa1, at2, rp1, rp2, rp3, rp4, rp5, rep;
      Float dt1dik, dt1djk, dt1djl, dt1dil, dt1dij;
      Float crlx, crly, crlz;
      bren_vector dt2dik, dt2dij;
      if(ln == i || jatom_pair[l].lcheck != 1) continue;
      ++nl;
      if(fabs(sinl[nl]) < 1.0e-01) continue;
      sinl2 = sinl[nl]*sinl[nl];
      cl = jatom_pair[l].cor;
      rcl = jatom_pair[l].rcor;

      if(getKtype(ln) == 2) {
        fcl = 1.0;
        dfcl = 0.0;
        /* FIXME Another trig computation that is probably in some lookup
           table somewhere.  Tim Freeman 11 Sep 2000 */
        if(rcl >= 1.60) continue;
        if(rcl >= 1.30) {
          Float dtemp = PIDT*(rcl-1.30);
          fcl = (1.0+cos(dtemp))/2.0;
          dfcl = -PIDT/2.0*sin(dtemp);
        }
      } else {
        fcl = jatom_pair[l].ww;
        dfcl = jatom_pair[l].dww;
      }
      t1 = rck*rcl*sij*sij*sink[nk]*sinl[nl];
      
      dt1dik = 1.0/rck/rck - dctik[nk]/sink2*cosk_nk;
      
      dt1djk = -dctjk[nk]/sink2*cosk_nk;
      
      dt1djl = 1.0/rcl/rcl-dctjl[nl]/sinl2*cosl[nl];
      
      dt1dil = -dctil[nl]/sinl2*cosl[nl];

      dt1dij = 2.0/sij/sij-dctij[nk]/sink2*cosk_nk-dctji[nl]/sinl2*cosl[nl];

      crlx = cj[1]*cl[2]-cl[1]*cj[2];
      crly = cj[2]*cl[0]-cl[2]*cj[0];
      crlz = cj[0]*cl[1]-cl[0]*cj[1];

      t2 = crkx*crlx+crky*crly+crkz*crlz;

      cw = t2/t1;
      bt = (1.0-cw*cw);
      btor += bt*fck*fcl;

      dt2dik[0] = -cj[2]*crly+cj[1]*crlz;
      dt2dik[1] = -cj[0]*crlz+cj[2]*crlx;
      dt2dik[2] = -cj[1]*crlx+cj[0]*crly;

      dt2dij[0] = ck[2]*crly-cl[2]*crky-ck[1]*crlz+cl[1]*crkz;
      dt2dij[1] = ck[0]*crlz-cl[0]*crkz-ck[2]*crlx+cl[2]*crkx;
      dt2dij[2] = ck[1]*crlx-cl[1]*crkx-ck[0]*crly+cl[0]*crky;

      aaa1 = vatt_ator*bt;
      aa = -vatt_ator*2.0*cw/t1*fcl*fck;
      at2 = aa*t2;

      rp1 = -dt1dij*at2;
      rp2 = -dt1dik*at2+aaa1*fcl*dfck/rck;
      rp3 = -dt1djl*at2+aaa1*fck*dfcl/rcl;
      rp4 = -dt1djk*at2;
      rp5 = -dt1dil*at2;

      transForce(i, jn, rp1*cj + aa*dt2dij);
      transForce(i, kn, rp2*ck + aa*dt2dik);
      transForce(jn, ln, rp3*cl + aa*dt2djl);
      transForce(jn, kn, rp4*xk_nk);
      transForce(i, ln, rp5*xl[nl]);
    }
  }

  *btot += btor*ator;
  *dradi += datori*btor;
  *dradj += datorj*btor;
  *drdc += datorc*btor;
}